home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / gnu / readline.lha / readline / doc / texinfo.tex < prev   
Text File  |  1991-05-01  |  88KB  |  2,736 lines

  1. %% TeX macros to handle texinfo files
  2.  
  3. %   Copyright (C) 1985, 1986, 1988, 1990, 1991 Free Software Foundation, Inc.
  4.  
  5. %This texinfo.tex file is free software; you can redistribute it and/or
  6. %modify it under the terms of the GNU General Public License as
  7. %published by the Free Software Foundation; either version 1, or (at
  8. %your option) any later version.
  9.  
  10. %This texinfo.tex file is distributed in the hope that it will be
  11. %useful, but WITHOUT ANY WARRANTY; without even the implied warranty
  12. %of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  13. %General Public License for more details.
  14.  
  15. %You should have received a copy of the GNU General Public License
  16. %along with this texinfo.tex file; see the file COPYING.  If not, write
  17. %to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139,
  18. %USA.
  19.  
  20.  
  21. %In other words, you are welcome to use, share and improve this program.
  22. %You are forbidden to forbid anyone else to use, share and improve
  23. %what you give them.   Help stamp out software-hoarding!
  24.  
  25. \def\texinfoversion{2.41}
  26. \message{Loading texinfo package [Version \texinfoversion]:}
  27. \message{}
  28.  
  29. % Print the version number if in a .fmt file.
  30. \everyjob{\message{[Texinfo version \texinfoversion]}\message{}}
  31.  
  32. % Save some parts of plain tex whose names we will redefine.
  33.  
  34. \let\ptexlbrace=\{
  35. \let\ptexrbrace=\}
  36. \let\ptexdots=\dots
  37. \let\ptexdot=\.
  38. \let\ptexstar=\*
  39. \let\ptexend=\end
  40. \let\ptexbullet=\bullet
  41. \let\ptexb=\b
  42. \let\ptexc=\c
  43. \let\ptexi=\i
  44. \let\ptext=\t
  45. \let\ptexl=\l
  46. \let\ptexL=\L
  47.  
  48. \def\tie{\penalty 10000\ }     % Save plain tex definition of ~.
  49.  
  50. \message{Basics,}
  51. \chardef\other=12
  52.  
  53. \hyphenation{ap-pen-dix}
  54. \hyphenation{mini-buf-fer mini-buf-fers}
  55. \hyphenation{eshell}
  56.  
  57. % Margin to add to right of even pages, to left of odd pages.
  58. \newdimen \bindingoffset  \bindingoffset=0pt
  59. \newdimen \normaloffset   \normaloffset=\hoffset
  60. \newdimen\pagewidth \newdimen\pageheight
  61. \pagewidth=\hsize \pageheight=\vsize
  62.  
  63. %---------------------Begin change-----------------------
  64. %
  65. % Dimensions to add cropmarks at corners Added by P. A. MacKay, 12 Nov. 1986
  66. %
  67. \newdimen\cornerlong \newdimen\cornerthick
  68. \newdimen \topandbottommargin
  69. \newdimen \outerhsize \newdimen \outervsize
  70. \cornerlong=1pc\cornerthick=.3pt    % These set size of cropmarks
  71. \outerhsize=7in
  72. \outervsize=9.5in
  73. \topandbottommargin=.75in
  74. %
  75. %---------------------End change-----------------------
  76.  
  77. % \onepageout takes a vbox as an argument.  Note that \pagecontents
  78. % does insertions itself, but you have to call it yourself.
  79. \chardef\PAGE=255  \output={\onepageout{\pagecontents\PAGE}}
  80. \def\onepageout#1{\hoffset=\normaloffset
  81. \ifodd\pageno  \advance\hoffset by \bindingoffset
  82. \else \advance\hoffset by -\bindingoffset\fi
  83. {\escapechar=`\\\relax % makes sure backslash is used in output files.
  84. \shipout\vbox{{\let\hsize=\pagewidth \makeheadline} \pagebody{#1}%
  85. {\let\hsize=\pagewidth \makefootline}}}%
  86. \advancepageno \ifnum\outputpenalty>-20000 \else\dosupereject\fi}
  87.  
  88.  
  89. % Here is a modification of the main output routine for Near East Publications
  90. % This provides right-angle cropmarks at all four corners.
  91. % The contents of the page are centerlined into the cropmarks,
  92. % and any desired binding offset is added as an \hskip on either
  93. % site of the centerlined box.  (P. A. MacKay, 12 November, 1986)
  94. %
  95. \def\croppageout#1{\hoffset=0pt % make sure this doesn't mess things up
  96.          \shipout
  97.          \vbox to \outervsize{\hsize=\outerhsize
  98.                  \vbox{\line{\ewtop\hfill\ewtop}}
  99.                  \nointerlineskip
  100.                  \line{\vbox{\moveleft\cornerthick\nstop}
  101.                        \hfill
  102.                        \vbox{\moveright\cornerthick\nstop}}
  103.                  \vskip \topandbottommargin
  104.                  \centerline{\ifodd\pageno\hskip\bindingoffset\fi
  105.             \vbox{
  106.             {\let\hsize=\pagewidth \makeheadline}
  107.             \pagebody{#1}
  108.             {\let\hsize=\pagewidth \makefootline}}
  109.             \ifodd\pageno\else\hskip\bindingoffset\fi}
  110.          \vskip \topandbottommargin plus1fill minus1fill
  111.                  \boxmaxdepth\cornerthick
  112.                  \line{\vbox{\moveleft\cornerthick\nsbot}
  113.                        \hfill
  114.                        \vbox{\moveright\cornerthick\nsbot}}
  115.                  \nointerlineskip
  116.                  \vbox{\line{\ewbot\hfill\ewbot}}
  117.     }
  118.   \advancepageno 
  119.   \ifnum\outputpenalty>-20000 \else\dosupereject\fi}
  120. %
  121. % Do @cropmarks to get crop marks
  122. \def\cropmarks{\let\onepageout=\croppageout }
  123.  
  124. \def\pagebody#1{\vbox to\pageheight{\boxmaxdepth=\maxdepth #1}}
  125. {\catcode`\@ =11
  126. \gdef\pagecontents#1{\ifvoid\topins\else\unvbox\topins\fi
  127. \dimen@=\dp#1 \unvbox#1
  128. \ifvoid\footins\else\vskip\skip\footins\footnoterule \unvbox\footins\fi
  129. \ifr@ggedbottom \kern-\dimen@ \vfil \fi}
  130. }
  131.  
  132. %
  133. % Here are the rules for the cropmarks.  Note that they are
  134. % offset so that the space between them is truly \outerhsize or \outervsize
  135. % (P. A. MacKay, 12 November, 1986)
  136. %
  137. \def\ewtop{\vrule height\cornerthick depth0pt width\cornerlong}
  138. \def\nstop{\vbox
  139.   {\hrule height\cornerthick depth\cornerlong width\cornerthick}}
  140. \def\ewbot{\vrule height0pt depth\cornerthick width\cornerlong}
  141. \def\nsbot{\vbox
  142.   {\hrule height\cornerlong depth\cornerthick width\cornerthick}}
  143.  
  144. % Parse an argument, then pass it to #1.
  145. % The argument can be delimited with [...] or with "..." or braces
  146. % or it can be a whole line.
  147. % #1 should be a macro which expects
  148. % an ordinary undelimited TeX argument.
  149.  
  150. \def\parsearg #1{\let\next=#1\begingroup\obeylines\futurelet\temp\parseargx}
  151.  
  152. \def\parseargx{%
  153. \ifx \obeyedspace\temp \aftergroup\parseargdiscardspace \else%
  154. \aftergroup \parseargline %
  155. \fi \endgroup}
  156.  
  157. {\obeyspaces %
  158. \gdef\parseargdiscardspace {\begingroup\obeylines\futurelet\temp\parseargx}}
  159.  
  160. \gdef\obeyedspace{\ }
  161.  
  162. \def\parseargline{\begingroup \obeylines \parsearglinex}
  163. {\obeylines %
  164. \gdef\parsearglinex #1^^M{\endgroup \next {#1}}}
  165.  
  166. \def\flushcr{\ifx\par\lisppar \def\next##1{}\else \let\next=\relax \fi \next}
  167.  
  168. %% These are used to keep @begin/@end levels from running away
  169. %% Call \inENV within environments (after a \begingroup)
  170. \newif\ifENV \ENVfalse \def\inENV{\ifENV\relax\else\ENVtrue\fi}
  171. \def\ENVcheck{%
  172. \ifENV\errmessage{Still within an environment.  Type Return to continue.}
  173. \endgroup\fi} % This is not perfect, but it should reduce lossage
  174.  
  175. % @begin foo  is the same as @foo, for now.
  176. \newhelp\EMsimple{Type <Return> to continue}
  177.  
  178. \outer\def\begin{\parsearg\beginxxx}
  179.  
  180. \def\beginxxx #1{%
  181. \expandafter\ifx\csname #1\endcsname\relax
  182. {\errhelp=\EMsimple \errmessage{Undefined command @begin #1}}\else
  183. \csname #1\endcsname\fi}
  184.  
  185. %% @end foo executes the definition of \Efoo.
  186. %% foo can be delimited by doublequotes or brackets.
  187.  
  188. \def\end{\parsearg\endxxx}
  189.  
  190. \def\endxxx #1{%
  191. \expandafter\ifx\csname E#1\endcsname\relax
  192. \expandafter\ifx\csname #1\endcsname\relax
  193. \errmessage{Undefined command @end #1}\else
  194. \errorE{#1}\fi\fi
  195. \csname E#1\endcsname}
  196. \def\errorE#1{
  197. {\errhelp=\EMsimple \errmessage{@end #1 not within #1 environment}}}
  198.  
  199. % Single-spacing is done by various environments.
  200.  
  201. \newskip\singlespaceskip \singlespaceskip = \baselineskip
  202. \def\singlespace{%
  203. {\advance \baselineskip by -\singlespaceskip
  204. \kern \baselineskip}%
  205. \baselineskip=\singlespaceskip
  206. }
  207.  
  208. %% Simple single-character @ commands
  209.  
  210. % @@ prints an @
  211. % Kludge this until the fonts are right (grr).
  212. \def\@{{\tt \char '100}}
  213.  
  214. % Define @` and @' to be the same as ` and '
  215. % but suppressing ligatures.
  216. \def\`{{`}}
  217. \def\'{{'}}
  218.  
  219. % Used to generate quoted braces.
  220.  
  221. \def\mylbrace {{\tt \char '173}}
  222. \def\myrbrace {{\tt \char '175}}
  223. \let\{=\mylbrace
  224. \let\}=\myrbrace
  225.  
  226. % @: forces normal size whitespace following.
  227. \def\:{\spacefactor=1000 }
  228.  
  229. % @* forces a line break.
  230. \def\*{\hfil\break\hbox{}\ignorespaces}
  231.  
  232. % @. is an end-of-sentence period.
  233. \def\.{.\spacefactor=3000 }
  234.  
  235. % @w prevents a word break
  236. \def\w #1{\hbox{#1}}
  237.  
  238. % @group ... @end group  forces ... to be all on one page.
  239.  
  240. \def\group{\begingroup% \inENV ???
  241. \def \Egroup{\egroup\endgroup}
  242. \vbox\bgroup}
  243.  
  244. % @need space-in-mils
  245. % forces a page break if there is not space-in-mils remaining.
  246.  
  247. \newdimen\mil  \mil=0.001in
  248.  
  249. \def\need{\parsearg\needx}
  250.  
  251. \def\needx #1{\par %
  252. % This method tries to make TeX break the page naturally
  253. % if the depth of the box does not fit.
  254. {\baselineskip=0pt%
  255. \vtop to #1\mil{\vfil}\kern -#1\mil\penalty 10000
  256. \prevdepth=-1000pt
  257. }}
  258.  
  259. % @br   forces paragraph break
  260.  
  261. \let\br = \par
  262.  
  263. % @dots{}  output some dots
  264.  
  265. \def\dots{$\ldots$}
  266.  
  267. % @page    forces the start of a new page
  268.  
  269. \def\page{\par\vfill\supereject}
  270.  
  271. % @exdent text....
  272. % outputs text on separate line in roman font, starting at standard page margin
  273.  
  274. \def\exdent{\errmessage{@exdent in filled text}}
  275.   % @lisp, etc, define \exdent locally from \internalexdent
  276.  
  277. {\obeyspaces
  278. \gdef\internalexdent{\parsearg\exdentzzz}}
  279.  
  280. \def\exdentzzz #1{{\advance \leftskip by -\lispnarrowing
  281. \advance \hsize by -\leftskip
  282. \advance \hsize by -\rightskip
  283. \leftline{{\rm#1}}}}
  284.  
  285. % @include file    insert text of that file as input.
  286.  
  287. \def\include{\parsearg\includezzz}
  288. \def\includezzz #1{{\def\thisfile{#1}\input #1
  289. }}
  290.  
  291. \def\thisfile{}
  292.  
  293. % @center line   outputs that line, centered
  294.  
  295. \def\center{\parsearg\centerzzz}
  296. \def\centerzzz #1{{\advance\hsize by -\leftskip
  297. \advance\hsize by -\rightskip
  298. \centerline{#1}}}
  299.  
  300. % @sp n   outputs n lines of vertical space
  301.  
  302. \def\sp{\parsearg\spxxx}
  303. \def\spxxx #1{\par \vskip #1\baselineskip}
  304.  
  305. % @comment ...line which is ignored...
  306. % @c is the same as @comment
  307. % @ignore ... @end ignore  is another way to write a comment
  308.  
  309. \def\comment{\catcode 64=\other \catcode 123=\other \catcode 125=\other%
  310. \parsearg \commentxxx}
  311.  
  312. \def\commentxxx #1{\catcode 64=0 \catcode 123=1 \catcode 125=2 }
  313.  
  314. \let\c=\comment
  315.  
  316. % Prevent errors for section commands.
  317. % Used in @ignore and in failing conditionals.
  318. \def\ignoresections{%
  319. \let\chapter=\relax
  320. \let\unnumbered=\relax
  321. \let\top=\relax
  322. \let\unnumberedsec=\relax
  323. \let\unnumberedsection=\relax
  324. \let\unnumberedsubsec=\relax
  325. \let\unnumberedsubsection=\relax
  326. \let\unnumberedsubsubsec=\relax
  327. \let\unnumberedsubsubsection=\relax
  328. \let\section=\relax
  329. \let\subsec=\relax
  330. \let\subsubsec=\relax
  331. \let\subsection=\relax
  332. \let\subsubsection=\relax
  333. \let\appendix=\relax
  334. \let\appendixsec=\relax
  335. \let\appendixsection=\relax
  336. \let\appendixsubsec=\relax
  337. \let\appendixsubsection=\relax
  338. \let\appendixsubsubsec=\relax
  339. \let\appendixsubsubsection=\relax
  340. \let\contents=\relax
  341. \let\smallbook=\relax
  342. \let\titlepage=\relax
  343. }
  344.  
  345. \def\ignore{\begingroup\ignoresections\ignorexxx}
  346. \long\def\ignorexxx #1\end ignore{\endgroup\ignorespaces}
  347.  
  348. \def\direntry{\begingroup\direntryxxx}
  349. \long\def\direntryxxx #1\end direntry{\endgroup\ignorespaces}
  350.  
  351. % Conditionals to test whether a flag is set.
  352.  
  353. \outer\def\ifset{\begingroup\ignoresections\parsearg\ifsetxxx}
  354.  
  355. \def\ifsetxxx #1{\endgroup
  356. \expandafter\ifx\csname IF#1\endcsname\relax \let\temp=\ifsetfail
  357. \else \let\temp=\relax \fi
  358. \temp}
  359. \def\Eifset{}
  360. \def\ifsetfail{\begingroup\ignoresections\ifsetfailxxx}
  361. \long\def\ifsetfailxxx #1\end ifset{\endgroup\ignorespaces}
  362.  
  363. \outer\def\ifclear{\begingroup\ignoresections\parsearg\ifclearxxx}
  364.  
  365. \def\ifclearxxx #1{\endgroup
  366. \expandafter\ifx\csname IF#1\endcsname\relax \let\temp=\relax
  367. \else \let\temp=\ifclearfail \fi
  368. \temp}
  369. \def\Eifclear{}
  370. \def\ifclearfail{\begingroup\ignoresections\ifclearfailxxx}
  371. \long\def\ifclearfailxxx #1\end ifclear{\endgroup\ignorespaces}
  372.  
  373. % Some texinfo constructs that are trivial in tex
  374.  
  375. \def\iftex{}
  376. \def\Eiftex{}
  377. \def\ifinfo{\begingroup\ignoresections\ifinfoxxx}
  378. \long\def\ifinfoxxx #1\end ifinfo{\endgroup\ignorespaces}
  379.  
  380. \long\def\menu #1\end menu{}
  381. \def\asis#1{#1}
  382.  
  383. % @math means output in math mode.
  384. % We don't use $'s directly in the definition of \math because control
  385. % sequences like \math are expanded when the toc file is written.  Then,
  386. % we read the toc file back, the $'s will be normal characters (as they
  387. % should be, according to the definition of Texinfo).  So we must use a
  388. % control sequence to switch into and out of math mode.
  389. % This isn't quite enough for @math to work properly in indices, but it
  390. % seems unlikely it will ever be needed there.
  391. \let\implicitmath = $
  392. \def\math#1{\implicitmath #1\implicitmath}
  393.  
  394. \def\node{\ENVcheck\parsearg\nodezzz}
  395. \def\nodezzz#1{\nodexxx [#1,]}
  396. \def\nodexxx[#1,#2]{\gdef\lastnode{#1}}
  397. \let\lastnode=\relax
  398.  
  399. \def\donoderef{\ifx\lastnode\relax\else
  400. \expandafter\expandafter\expandafter\setref{\lastnode}\fi
  401. \let\lastnode=\relax}
  402.  
  403. \def\unnumbnoderef{\ifx\lastnode\relax\else
  404. \expandafter\expandafter\expandafter\unnumbsetref{\lastnode}\fi
  405. \let\lastnode=\relax}
  406.  
  407. \def\appendixnoderef{\ifx\lastnode\relax\else
  408. \expandafter\expandafter\expandafter\appendixsetref{\lastnode}\fi
  409. \let\lastnode=\relax}
  410.  
  411. \let\refill=\relax
  412.   
  413. % @setfilename is done at the beginning of every texinfo file.
  414. % So open here the files we need to have open while reading the input.
  415. % This makes it possible to make a .fmt file for texinfo.
  416. \def\setfilename{%
  417.    \readauxfile
  418.    \opencontents
  419.    \openindices
  420.    \fixbackslash  % Turn off hack to swallow `\input texinfo'.
  421.    \global\let\setfilename=\comment % Ignore extra @setfilename cmds.
  422.    \comment % Ignore the actual filename.
  423. }
  424.  
  425. \outer\def\bye{\pagealignmacro\tracingstats=1\ptexend}
  426.  
  427. \def\inforef #1{\inforefzzz #1,,,,**}
  428. \def\inforefzzz #1,#2,#3,#4**{See Info file \file{\losespace#3{}}, node \samp{\losespace#1{}}}
  429. \def\losespace #1{#1}
  430.  
  431. \message{fonts,}
  432.  
  433. % Font-change commands.
  434.  
  435. %% Try out Computer Modern fonts at \magstephalf
  436. \font\tenrm=cmr10 scaled \magstephalf
  437. \font\tentt=cmtt10 scaled \magstephalf
  438. % Instead of cmb10, you many want to use cmbx10.
  439. % cmbx10 is a prettier font on its own, but cmb10
  440. % looks better when embedded in a line with cmr10.
  441. \font\tenbf=cmb10 scaled \magstephalf 
  442. \font\tenit=cmti10 scaled \magstephalf
  443. \font\tensl=cmsl10 scaled \magstephalf
  444. \font\tensf=cmss10 scaled \magstephalf
  445. \def\li{\sf}
  446. \font\tensc=cmcsc10 scaled \magstephalf
  447.  
  448. % Fonts for @defun, etc.
  449. \font\defbf=cmbx10 scaled \magstep1 %was 1314
  450. \font\deftt=cmtt10 scaled \magstep1
  451. \def\df{\let\tt=\deftt \defbf}
  452.  
  453. % Fonts for indices and small examples.
  454. % We actually use the slanted font rather than the italic, 
  455. % because texinfo normally uses the slanted fonts for that.
  456. \font\ninett=cmtt9
  457. \font\indit=cmsl9 \font\indrm=cmr9
  458. \let\indtt=\ninett
  459. \def\indbf{\indrm} \def\indsl{\indit}
  460. \def\indexfonts{\let\it=\indit \let\sl=\indsl \let\bf=\indbf \let\rm=\indrm
  461. \let\tt=\indtt}
  462.  
  463. % Fonts for headings
  464. \font\chaprm=cmbx12 scaled \magstep2
  465. \font\chapit=cmti12 scaled \magstep2
  466. \font\chapsl=cmsl12 scaled \magstep2
  467. \font\chaptt=cmtt12 scaled \magstep2
  468. \font\chapsf=cmss12 scaled \magstep2
  469. \let\chapbf=\chaprm
  470.  
  471. \font\secrm=cmbx12 scaled \magstep1
  472. \font\secit=cmti12 scaled \magstep1
  473. \font\secsl=cmsl12 scaled \magstep1
  474. \font\sectt=cmtt12 scaled \magstep1
  475. \font\secsf=cmss12 scaled \magstep1
  476. \font\secbf=cmbx12 scaled \magstep1
  477.  
  478. % \font\ssecrm=cmbx10 scaled \magstep1    % This size an fontlooked bad.
  479. % \font\ssecit=cmti10 scaled \magstep1    % The letters were too crowded.
  480. % \font\ssecsl=cmsl10 scaled \magstep1
  481. % \font\ssectt=cmtt10 scaled \magstep1
  482. % \font\ssecsf=cmss10 scaled \magstep1
  483.  
  484. %\font\ssecrm=cmb10 scaled 1315    % Note the use of cmb rather than cmbx.
  485. %\font\ssecit=cmti10 scaled 1315    % Also, the size is a little larger than
  486. %\font\ssecsl=cmsl10 scaled 1315    % being scaled magstep1.
  487. %\font\ssectt=cmtt10 scaled 1315
  488. %\font\ssecsf=cmss10 scaled 1315
  489.  
  490. %\let\ssecbf=\ssecrm
  491.  
  492. \font\ssecrm=cmbx12 scaled \magstephalf
  493. \font\ssecit=cmti12 scaled \magstephalf
  494. \font\ssecsl=cmsl12 scaled \magstephalf
  495. \font\ssectt=cmtt12 scaled \magstephalf
  496. \font\ssecsf=cmss12 scaled \magstephalf
  497. \font\ssecbf=cmbx12 scaled \magstephalf
  498.  
  499. % Font for title
  500. % There seems to have been a confusion: two definitions of this font.
  501. % It is not clear why, or which one is better.
  502. \font\titlerm = cmbx12 scaled \magstep3
  503. \let\authorrm = \secrm
  504.  
  505. \def\textfonts{\let\rm=\tenrm\let\it=\tenit\let\sl=\tensl\let\bf=\tenbf%
  506. \let\smallcaps=\tensc\let\sf=\tensf}
  507. \def\chapfonts{\let\rm=\chaprm\let\it=\chapit\let\sl=\chapsl\let\bf=\chapbf\let\tt=\chaptt\let\sf=\chapsf}
  508. \def\secfonts{\let\rm=\secrm\let\it=\secit\let\sl=\secsl\let\bf=\secbf\let\tt=\sectt\let\sf=\secsf}
  509. \def\subsecfonts{\let\rm=\ssecrm\let\it=\ssecit\let\sl=\ssecsl\let\bf=\ssecbf\let\tt=\ssectt\let\sf=\ssecsf}
  510. % Count depth in font-changes, for error checks
  511. \newcount\fontdepth \fontdepth=0
  512.  
  513. % Fonts for short table of contents.
  514. \font\shortcontrm=cmr12
  515. \font\shortcontbf=cmbx12
  516. \font\shortcontsl=cmsl12
  517.  
  518. %% Add scribe-like font environments, plus @l for inline lisp (usually sans
  519. %% serif) and @ii for TeX italic
  520.  
  521. % \smartitalic{ARG} outputs arg in italics, followed by an italic correction
  522. % unless the following character is such as not to need one.
  523. \def\smartitalicx{\ifx\next,\else\ifx\next-\else\ifx\next.\else\/\fi\fi\fi}
  524. \def\smartitalic#1{{\sl #1}\futurelet\next\smartitalicx}
  525.  
  526. \let\i=\smartitalic
  527. \let\var=\smartitalic
  528. \let\dfn=\smartitalic
  529. \let\emph=\smartitalic
  530. \let\cite=\smartitalic
  531.  
  532. \def\b#1{{\bf #1}}
  533. \let\strong=\b
  534.  
  535. \def\t#1{{\tt \exhyphenpenalty=10000\rawbackslash \frenchspacing #1}\null}
  536. \let\ttfont = \t
  537. %\def\samp #1{`{\tt \rawbackslash \frenchspacing #1}'\null}
  538. \def\samp #1{`\tclose{#1}'\null}
  539. \def\key #1{{\tt \exhyphenpenalty=10000\uppercase{#1}}\null}
  540. \def\ctrl #1{{\tt \rawbackslash \hat}#1}
  541.  
  542. \let\file=\samp
  543.  
  544. % @code is a modification of @t,
  545. % which makes spaces the same size as normal in the surrounding text.
  546. \newdimen\tclosesave
  547. \newdimen\tcloserm
  548. \def\tclose#1{{\rm \tcloserm=\fontdimen2\font \tt \tclosesave=\fontdimen2\font
  549. \fontdimen2\font=\tcloserm
  550. % prevent breaking lines at hyphens.
  551. \exhyphenpenalty=10000
  552. \def\ {{\fontdimen2\font=\tclosesave{} }}%
  553.  \rawbackslash \frenchspacing #1\fontdimen2\font=\tclosesave}\null}
  554. \let\code=\tclose
  555. %\let\exp=\tclose  %Was temporary
  556.  
  557. % @kbd is like @code, except that if the argument is just one @key command, 
  558. % then @kbd has no effect.
  559.  
  560. \def\xkey{\key}
  561. \def\kbdfoo#1#2#3\par{\def\one{#1}\def\three{#3}\def\threex{??}%
  562. \ifx\one\xkey\ifx\threex\three \key{#2}%
  563. \else\tclose{\look}\fi
  564. \else\tclose{\look}\fi}
  565.  
  566. \def\kbd#1{\def\look{#1}\expandafter\kbdfoo\look??\par}
  567.  
  568. \def\l#1{{\li #1}\null}        % 
  569.  
  570. \def\r#1{{\rm #1}}        % roman font
  571. % Use of \lowercase was suggested.
  572. \def\sc#1{{\smallcaps#1}}    % smallcaps font
  573. \def\ii#1{{\it #1}}        % italic font
  574.  
  575. \message{page headings,}
  576.  
  577. \newskip\titlepagetopglue \titlepagetopglue = 1.5in
  578. \newskip\titlepagebottomglue \titlepagebottomglue = 2pc
  579.  
  580. % First the title page.  Must do @settitle before @titlepage.
  581. \def\titlefont#1{{\titlerm #1}}
  582.  
  583. \newtoks\realeverypar
  584. \newif\ifseenauthor
  585. \newif\iffinishedtitlepage
  586.  
  587. \def\titlepage{\begingroup \parindent=0pt \textfonts
  588.    \let\subtitlerm=\tenrm
  589. % I deinstalled the following change because \cmr12 is undefined.
  590. % This change was not in the ChangeLog anyway.  --rms.
  591. %   \let\subtitlerm=\cmr12
  592.    \def\subtitlefont{\subtitlerm \normalbaselineskip = 13pt \normalbaselines}%
  593.    %
  594.    \def\authorfont{\authorrm \normalbaselineskip = 16pt \normalbaselines}%
  595.    %
  596.    % Leave some space at the very top of the page.
  597.    \vglue\titlepagetopglue
  598.    %
  599.    % Now you can print the title using @title.
  600.    \def\title{\parsearg\titlezzz}%
  601.    \def\titlezzz##1{\leftline{\titlefont{##1}}
  602.             % print a rule at the page bottom also.
  603.             \finishedtitlepagefalse
  604.             \vskip4pt \hrule height 4pt \vskip4pt}%
  605.    % No rule at page bottom unless we print one at the top with @title.
  606.    \finishedtitlepagetrue
  607.    %
  608.    % Now you can put text using @subtitle.
  609.    \def\subtitle{\parsearg\subtitlezzz}%
  610.    \def\subtitlezzz##1{{\subtitlefont \rightline{##1}}}%
  611.    %
  612.    % @author should come last, but may come many times.
  613.    \def\author{\parsearg\authorzzz}%
  614.    \def\authorzzz##1{\ifseenauthor\else\vskip 0pt plus 1filll\seenauthortrue\fi
  615.       {\authorfont \leftline{##1}}}%
  616.    %  
  617.    % Most title ``pages'' are actually two pages long, with space
  618.    % at the top of the second.  We don't want the ragged left on the second.
  619.    \let\oldpage = \page
  620.    \def\page{%
  621.       \iffinishedtitlepage\else
  622.      \finishtitlepage
  623.       \fi
  624.       \oldpage
  625.       \let\page = \oldpage
  626.       \hbox{}}%
  627. %   \def\page{\oldpage \hbox{}}
  628. }
  629.  
  630. \def\Etitlepage{%
  631.    \iffinishedtitlepage\else
  632.       \finishtitlepage
  633.    \fi
  634.    % It is important to do the page break before ending the group,
  635.    % because the headline and footline are only empty inside the group.
  636.    % If we use the new definition of \page, we always get a blank page
  637.    % after the title page, which we certainly don't want.
  638.    \oldpage
  639.    \endgroup
  640.    \HEADINGSon
  641. }
  642.  
  643. \def\finishtitlepage{%
  644.    \vskip4pt \hrule height 2pt
  645.    \vskip\titlepagebottomglue
  646.    \finishedtitlepagetrue
  647. }
  648.  
  649. %%% Set up page headings and footings.
  650.  
  651. \let\thispage=\folio
  652.  
  653. \newtoks \evenheadline    % Token sequence for heading line of even pages
  654. \newtoks \oddheadline     % Token sequence for heading line of odd pages
  655. \newtoks \evenfootline    % Token sequence for footing line of even pages
  656. \newtoks \oddfootline     % Token sequence for footing line of odd pages
  657.  
  658. % Now make Tex use those variables
  659. \headline={{\textfonts\rm \ifodd\pageno \the\oddheadline \else \the\evenheadline \fi}}
  660. \footline={{\textfonts\rm \ifodd\pageno \the\oddfootline \else \the\evenfootline \fi}\HEADINGShook}
  661. \let\HEADINGShook=\relax
  662.  
  663. % Commands to set those variables.
  664. % For example, this is what  @headings on  does
  665. % @evenheading @thistitle|@thispage|@thischapter
  666. % @oddheading @thischapter|@thispage|@thistitle
  667. % @evenfooting @thisfile||
  668. % @oddfooting ||@thisfile
  669.  
  670. \def\evenheading{\parsearg\evenheadingxxx}
  671. \def\oddheading{\parsearg\oddheadingxxx}
  672. \def\everyheading{\parsearg\everyheadingxxx}
  673.  
  674. \def\evenfooting{\parsearg\evenfootingxxx}
  675. \def\oddfooting{\parsearg\oddfootingxxx}
  676. \def\everyfooting{\parsearg\everyfootingxxx}
  677.  
  678. {\catcode`\@=0 %
  679.  
  680. \gdef\evenheadingxxx #1{\evenheadingyyy #1@|@|@|@|\finish}
  681. \gdef\evenheadingyyy #1@|#2@|#3@|#4\finish{%
  682. \global\evenheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
  683.  
  684. \gdef\oddheadingxxx #1{\oddheadingyyy #1@|@|@|@|\finish}
  685. \gdef\oddheadingyyy #1@|#2@|#3@|#4\finish{%
  686. \global\oddheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
  687.  
  688. \gdef\everyheadingxxx #1{\everyheadingyyy #1@|@|@|@|\finish}
  689. \gdef\everyheadingyyy #1@|#2@|#3@|#4\finish{%
  690. \global\evenheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}
  691. \global\oddheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
  692.  
  693. \gdef\evenfootingxxx #1{\evenfootingyyy #1@|@|@|@|\finish}
  694. \gdef\evenfootingyyy #1@|#2@|#3@|#4\finish{%
  695. \global\evenfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
  696.  
  697. \gdef\oddfootingxxx #1{\oddfootingyyy #1@|@|@|@|\finish}
  698. \gdef\oddfootingyyy #1@|#2@|#3@|#4\finish{%
  699. \global\oddfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
  700.  
  701. \gdef\everyfootingxxx #1{\everyfootingyyy #1@|@|@|@|\finish}
  702. \gdef\everyfootingyyy #1@|#2@|#3@|#4\finish{%
  703. \global\evenfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}}
  704. \global\oddfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
  705. %
  706. }% unbind the catcode of @.
  707.  
  708. % @headings double    turns headings on for double-sided printing.
  709. % @headings single    turns headings on for single-sided printing.
  710. % @headings off        turns them off.
  711. % @headings on        same as @headings double, retained for compatibility.
  712. % @headings after    turns on double-sided headings after this page.
  713. % @headings doubleafter    turns on double-sided headings after this page.
  714. % @headings singleafter turns on single-sided headings after this page.
  715. % By default, they are off.
  716.  
  717. \def\headings #1 {\csname HEADINGS#1\endcsname}
  718.  
  719. \def\HEADINGSoff{
  720. \global\evenheadline={\hfil} \global\evenfootline={\hfil}
  721. \global\oddheadline={\hfil} \global\oddfootline={\hfil}}
  722. \HEADINGSoff
  723. % When we turn headings on, set the page number to 1.
  724. % For double-sided printing, put current file name in lower left corner,
  725. % chapter name on inside top of right hand pages, document
  726. % title on inside top of left hand pages, and page numbers on outside top
  727. % edge of all pages.
  728. \def\HEADINGSdouble{
  729. %\pagealignmacro
  730. \global\pageno=1
  731. \global\evenfootline={\hfil}
  732. \global\oddfootline={\hfil}
  733. \global\evenheadline={\line{\folio\hfil\thistitle}}
  734. \global\oddheadline={\line{\thischapter\hfil\folio}}
  735. }
  736. % For single-sided printing, chapter title goes across top left of page,
  737. % page number on top right.
  738. \def\HEADINGSsingle{
  739. %\pagealignmacro
  740. \global\pageno=1
  741. \global\evenfootline={\hfil}
  742. \global\oddfootline={\hfil}
  743. \global\evenheadline={\line{\thischapter\hfil\folio}}
  744. \global\oddheadline={\line{\thischapter\hfil\folio}}
  745. }
  746. \def\HEADINGSon{\HEADINGSdouble}
  747.  
  748. \def\HEADINGSafter{\let\HEADINGShook=\HEADINGSdoublex}
  749. \let\HEADINGSdoubleafter=\HEADINGSafter
  750. \def\HEADINGSdoublex{%
  751. \global\evenfootline={\hfil}
  752. \global\oddfootline={\hfil}
  753. \global\evenheadline={\line{\folio\hfil\thistitle}}
  754. \global\oddheadline={\line{\thischapter\hfil\folio}}
  755. }
  756.  
  757. \def\HEADINGSsingleafter{\let\HEADINGShook=\HEADINGSsinglex}
  758. \def\HEADINGSsinglex{%
  759. \global\evenfootline={\hfil}
  760. \global\oddfootline={\hfil}
  761. \global\evenheadline={\line{\thischapter\hfil\folio}}
  762. \global\oddheadline={\line{\thischapter\hfil\folio}}
  763. }
  764.  
  765. % Subroutines used in generating headings
  766. % Produces Day Month Year style of output.
  767. \def\today{\number\day\space
  768. \ifcase\month\or
  769. January\or February\or March\or April\or May\or June\or
  770. July\or August\or September\or October\or November\or December\fi
  771. \space\number\year}
  772.  
  773. % Use this if you want the Month Day, Year style of output.
  774. %\def\today{\ifcase\month\or
  775. %January\or February\or March\or April\or May\or June\or
  776. %July\or August\or September\or October\or November\or December\fi
  777. %\space\number\day, \number\year}
  778.  
  779. % @settitle line...  specifies the title of the document, for headings
  780. % It generates no output of its own
  781.  
  782. \def\thistitle{No Title}
  783. \def\settitle{\parsearg\settitlezzz}
  784. \def\settitlezzz #1{\gdef\thistitle{#1}}
  785.  
  786. \message{tables,}
  787.  
  788. % @tabs -- simple alignment
  789.  
  790. % These don't work.  For one thing, \+ is defined as outer.
  791. % So these macros cannot even be defined.
  792.  
  793. %\def\tabs{\parsearg\tabszzz}
  794. %\def\tabszzz #1{\settabs\+#1\cr}
  795. %\def\tabline{\parsearg\tablinezzz}
  796. %\def\tablinezzz #1{\+#1\cr}
  797. %\def\&{&}
  798.  
  799. % Tables -- @table, @ftable, @item(x), @kitem(x), @xitem(x).
  800.  
  801. % default indentation of table text
  802. \newdimen\tableindent \tableindent=.8in
  803. % default indentation of @itemize and @enumerate text
  804. \newdimen\itemindent  \itemindent=.3in
  805. % margin between end of table item and start of table text.
  806. \newdimen\itemmargin  \itemmargin=.1in
  807.  
  808. % used internally for \itemindent minus \itemmargin
  809. \newdimen\itemmax
  810.  
  811. % Note @table and @ftable define @item, @itemx, etc., with these defs.
  812. % They also define \itemindex
  813. % to index the item name in whatever manner is desired (perhaps none).
  814.  
  815. \def\internalBitem{\smallbreak \parsearg\itemzzz}
  816. \def\internalBitemx{\par \parsearg\itemzzz}
  817.  
  818. \def\internalBxitem "#1"{\def\xitemsubtopix{#1} \smallbreak \parsearg\xitemzzz}
  819. \def\internalBxitemx "#1"{\def\xitemsubtopix{#1} \par \parsearg\xitemzzz}
  820.  
  821. \def\internalBkitem{\smallbreak \parsearg\kitemzzz}
  822. \def\internalBkitemx{\par \parsearg\kitemzzz}
  823.  
  824. \def\kitemzzz #1{\dosubind {kw}{\code{#1}}{for {\bf \lastfunction}}\itemzzz {#1}}
  825.  
  826. \def\xitemzzz #1{\dosubind {kw}{\code{#1}}{for {\bf \xitemsubtopic}}\itemzzz {#1}}
  827.  
  828. \def\itemzzz #1{\begingroup %
  829. \advance \hsize by -\rightskip %
  830. \advance \hsize by -\leftskip %
  831. \setbox0=\hbox{\itemfont{#1}}%
  832. \itemindex{#1}%
  833. \parskip=0in %
  834. \noindent %
  835. \ifdim \wd0>\itemmax %
  836. \vadjust{\penalty 10000}%
  837. \hbox to \hsize{\hskip -\tableindent\box0\hss}\ %
  838. \else %
  839. \hbox to 0pt{\hskip -\tableindent\box0\hss}%
  840. \fi %
  841. \endgroup %
  842. }
  843.  
  844. \def\item{\errmessage{@item while not in a table}}
  845. \def\itemx{\errmessage{@itemx while not in a table}}
  846. \def\kitem{\errmessage{@kitem while not in a table}}
  847. \def\kitemx{\errmessage{@kitemx while not in a table}}
  848. \def\xitem{\errmessage{@xitem while not in a table}}
  849. \def\xitemx{\errmessage{@xitemx while not in a table}}
  850.  
  851. %% Contains a kludge to get @end[description] to work
  852. \def\description{\tablez{\dontindex}{1}{}{}{}{}}
  853.  
  854. \def\table{\begingroup\inENV\obeylines\obeyspaces\tablex}
  855. {\obeylines\obeyspaces%
  856. \gdef\tablex #1^^M{%
  857. \tabley\dontindex#1        \endtabley}}
  858.  
  859. \def\ftable{\begingroup\inENV\obeylines\obeyspaces\ftablex}
  860. {\obeylines\obeyspaces%
  861. \gdef\ftablex #1^^M{%
  862. \tabley\fnitemindex#1        \endtabley
  863. \def\Eftable{\endgraf\endgroup\afterenvbreak}%
  864. \let\Etable=\relax}}
  865.  
  866. \def\dontindex #1{}
  867. \def\fnitemindex #1{\doind {fn}{\code{#1}}}%
  868.  
  869. {\obeyspaces %
  870. \gdef\tabley#1#2 #3 #4 #5 #6 #7\endtabley{\endgroup%
  871. \tablez{#1}{#2}{#3}{#4}{#5}{#6}}}
  872.  
  873. \def\tablez #1#2#3#4#5#6{%
  874. \aboveenvbreak %
  875. \begingroup %
  876. \def\Edescription{\Etable}% Neccessary kludge.
  877. \let\itemindex=#1%
  878. \ifnum 0#3>0 \advance \leftskip by #3\mil \fi %
  879. \ifnum 0#4>0 \tableindent=#4\mil \fi %
  880. \ifnum 0#5>0 \advance \rightskip by #5\mil \fi %
  881. \def\itemfont{#2}%
  882. \itemmax=\tableindent %
  883. \advance \itemmax by -\itemmargin %
  884. \advance \leftskip by \tableindent %
  885. \parindent = 0pt
  886. \parskip = \smallskipamount
  887. \ifdim \parskip=0pt \parskip=2pt \fi%
  888. \def\Etable{\endgraf\endgroup\afterenvbreak}%
  889. \let\item = \internalBitem %
  890. \let\itemx = \internalBitemx %
  891. \let\kitem = \internalBkitem %
  892. \let\kitemx = \internalBkitemx %
  893. \let\xitem = \internalBxitem %
  894. \let\xitemx = \internalBxitemx %
  895. }
  896.  
  897. % This is the counter used by @enumerate, which is really @itemize
  898.  
  899. \newcount \itemno
  900.  
  901. \def\itemize{\parsearg\itemizezzz}
  902.  
  903. \def\itemizezzz #1{\itemizey {#1}{\Eitemize}}
  904.  
  905. \def\itemizey #1#2{%
  906. \aboveenvbreak %
  907. \begingroup %
  908. \itemno = 0 %
  909. \itemmax=\itemindent %
  910. \advance \itemmax by -\itemmargin %
  911. \advance \leftskip by \itemindent %
  912. \parindent = 0pt
  913. \parskip = \smallskipamount
  914. \ifdim \parskip=0pt \parskip=2pt \fi%
  915. \def#2{\endgraf\endgroup\afterenvbreak}%
  916. \def\itemcontents{#1}%
  917. \let\item=\itemizeitem}
  918.  
  919. \def\bullet{$\ptexbullet$}
  920. \def\minus{$-$}
  921.  
  922. % Set sfcode to normal for the chars that usually have another value.
  923. % These are `.?!:;,'
  924. \def\frenchspacing{\sfcode46=1000 \sfcode63=1000 \sfcode33=1000
  925.   \sfcode58=1000 \sfcode59=1000 \sfcode44=1000 }
  926.  
  927. \def\enumerate{\itemizey{\the\itemno.}\Eenumerate\flushcr}
  928.  
  929. % Definition of @item while inside @itemize.
  930.  
  931. \def\itemizeitem{%
  932. \advance\itemno by 1
  933. {\let\par=\endgraf \smallbreak}%
  934. \ifhmode \errmessage{\in hmode at itemizeitem}\fi
  935. {\parskip=0in \hskip 0pt
  936. \hbox to 0pt{\hss \itemcontents\hskip \itemmargin}%
  937. \vadjust{\penalty 300}}%
  938. \flushcr}
  939.  
  940. \message{indexing,}
  941. % Index generation facilities
  942.  
  943. % Define \newwrite to be identical to plain tex's \newwrite
  944. % except not \outer, so it can be used within \newindex.
  945. {\catcode`\@=11
  946. \gdef\newwrite{\alloc@7\write\chardef\sixt@@n}}
  947.  
  948. % \newindex {foo} defines an index named foo.
  949. % It automatically defines \fooindex such that
  950. % \fooindex ...rest of line... puts an entry in the index foo.
  951. % It also defines \fooindfile to be the number of the output channel for
  952. % the file that    accumulates this index.  The file's extension is foo.
  953. % The name of an index should be no more than 2 characters long
  954. % for the sake of vms.
  955.  
  956. \def\newindex #1{
  957. \expandafter\newwrite \csname#1indfile\endcsname% Define number for output file
  958. \openout \csname#1indfile\endcsname \jobname.#1    % Open the file
  959. \expandafter\xdef\csname#1index\endcsname{%    % Define \xxxindex
  960. \noexpand\doindex {#1}}
  961. }
  962.  
  963. % @defindex foo  ==  \newindex{foo}
  964.  
  965. \def\defindex{\parsearg\newindex}
  966.  
  967. % Define @defcodeindex, like @defindex except put all entries in @code.
  968.  
  969. \def\newcodeindex #1{
  970. \expandafter\newwrite \csname#1indfile\endcsname% Define number for output file
  971. \openout \csname#1indfile\endcsname \jobname.#1    % Open the file
  972. \expandafter\xdef\csname#1index\endcsname{%    % Define \xxxindex
  973. \noexpand\docodeindex {#1}}
  974. }
  975.  
  976. \def\defcodeindex{\parsearg\newcodeindex}
  977.  
  978. % @synindex foo bar    makes index foo feed into index bar.
  979. % Do this instead of @defindex foo if you don't want it as a separate index.
  980. \def\synindex #1 #2 {%
  981. \expandafter\let\expandafter\synindexfoo\expandafter=\csname#2indfile\endcsname
  982. \expandafter\let\csname#1indfile\endcsname=\synindexfoo
  983. \expandafter\xdef\csname#1index\endcsname{%    % Define \xxxindex
  984. \noexpand\doindex {#2}}%
  985. }
  986.  
  987. % @syncodeindex foo bar   similar, but put all entries made for index foo
  988. % inside @code.
  989. \def\syncodeindex #1 #2 {%
  990. \expandafter\let\expandafter\synindexfoo\expandafter=\csname#2indfile\endcsname
  991. \expandafter\let\csname#1indfile\endcsname=\synindexfoo
  992. \expandafter\xdef\csname#1index\endcsname{%    % Define \xxxindex
  993. \noexpand\docodeindex {#2}}%
  994. }
  995.  
  996. % Define \doindex, the driver for all \fooindex macros.
  997. % Argument #1 is generated by the calling \fooindex macro,
  998. %  and it is "foo", the name of the index.
  999.  
  1000. % \doindex just uses \parsearg; it calls \doind for the actual work.
  1001. % This is because \doind is more useful to call from other macros.
  1002.  
  1003. % There is also \dosubind {index}{topic}{subtopic}
  1004. % which makes an entry in a two-level index such as the operation index.
  1005.  
  1006. \def\doindex#1{\edef\indexname{#1}\parsearg\singleindexer}
  1007. \def\singleindexer #1{\doind{\indexname}{#1}}
  1008.  
  1009. % like the previous two, but they put @code around the argument.
  1010. \def\docodeindex#1{\edef\indexname{#1}\parsearg\singlecodeindexer}
  1011. \def\singlecodeindexer #1{\doind{\indexname}{\code{#1}}}
  1012.  
  1013. \def\indexdummies{%
  1014. \def\_{{\realbackslash normalunderscore}}%
  1015. \def\w{\realbackslash w }%
  1016. \def\bf{\realbackslash bf }%
  1017. \def\rm{\realbackslash rm }%
  1018. \def\sl{\realbackslash sl }%
  1019. \def\sf{\realbackslash sf}%
  1020. \def\tt{\realbackslash tt}%
  1021. \def\gtr{\realbackslash gtr}%
  1022. \def\less{\realbackslash less}%
  1023. \def\hat{\realbackslash hat}%
  1024. \def\char{\realbackslash char}%
  1025. \def\TeX{\realbackslash TeX}%
  1026. \def\dots{\realbackslash dots }%
  1027. \def\copyright{\realbackslash copyright }%
  1028. \def\tclose##1{\realbackslash tclose {##1}}%
  1029. \def\code##1{\realbackslash code {##1}}%
  1030. \def\samp##1{\realbackslash samp {##1}}%
  1031. \def\t##1{\realbackslash r {##1}}%
  1032. \def\r##1{\realbackslash r {##1}}%
  1033. \def\i##1{\realbackslash i {##1}}%
  1034. \def\b##1{\realbackslash b {##1}}%
  1035. \def\cite##1{\realbackslash cite {##1}}%
  1036. \def\key##1{\realbackslash key {##1}}%
  1037. \def\file##1{\realbackslash file {##1}}%
  1038. \def\var##1{\realbackslash var {##1}}%
  1039. \def\kbd##1{\realbackslash kbd {##1}}%
  1040. }
  1041.  
  1042. % \indexnofonts no-ops all font-change commands.
  1043. % This is used when outputting the strings to sort the index by.
  1044. \def\indexdummyfont#1{#1}
  1045. \def\indexdummytex{TeX}
  1046. \def\indexdummydots{...}
  1047.  
  1048. \def\indexnofonts{%
  1049. \let\w=\indexdummyfont
  1050. \let\t=\indexdummyfont
  1051. \let\r=\indexdummyfont
  1052. \let\i=\indexdummyfont
  1053. \let\b=\indexdummyfont
  1054. \let\emph=\indexdummyfont
  1055. \let\strong=\indexdummyfont
  1056. \let\cite=\indexdummyfont
  1057. \let\sc=\indexdummyfont
  1058. %Don't no-op \tt, since it isn't a user-level command
  1059. % and is used in the definitions of the active chars like <, >, |...
  1060. %\let\tt=\indexdummyfont
  1061. \let\tclose=\indexdummyfont
  1062. \let\code=\indexdummyfont
  1063. \let\file=\indexdummyfont
  1064. \let\samp=\indexdummyfont
  1065. \let\kbd=\indexdummyfont
  1066. \let\key=\indexdummyfont
  1067. \let\var=\indexdummyfont
  1068. \let\TeX=\indexdummytex
  1069. \let\dots=\indexdummydots
  1070. }
  1071.  
  1072. % To define \realbackslash, we must make \ not be an escape.
  1073. % We must first make another character (@) an escape
  1074. % so we do not become unable to do a definition.
  1075.  
  1076. {\catcode`\@=0 \catcode`\\=\other
  1077. @gdef@realbackslash{\}}
  1078.  
  1079. \let\indexbackslash=0  %overridden during \printindex.
  1080.  
  1081. \def\doind #1#2{%
  1082. {\indexdummies % Must do this here, since \bf, etc expand at this stage
  1083. \count10=\lastpenalty %
  1084. \escapechar=`\\%
  1085. {\let\folio=0% Expand all macros now EXCEPT \folio
  1086. \def\rawbackslashxx{\indexbackslash}% \indexbackslash isn't defined now
  1087. % so it will be output as is; and it will print as backslash in the indx.
  1088. %
  1089. % Now process the index-string once, with all font commands turned off,
  1090. % to get the string to sort the index by.
  1091. {\indexnofonts
  1092. \xdef\temp1{#2}%
  1093. }%
  1094. % Now produce the complete index entry.  We process the index-string again,
  1095. % this time with font commands expanded, to get what to print in the index.
  1096. \edef\temp{%
  1097. \write \csname#1indfile\endcsname{%
  1098. \realbackslash entry {\temp1}{\folio}{#2}}}%
  1099. \temp }%
  1100. \penalty\count10}}
  1101.  
  1102. \def\dosubind #1#2#3{%
  1103. {\indexdummies % Must do this here, since \bf, etc expand at this stage
  1104. \count10=\lastpenalty %
  1105. \escapechar=`\\%
  1106. {\let\folio=0%
  1107. \def\rawbackslashxx{\indexbackslash}%
  1108. %
  1109. % Now process the index-string once, with all font commands turned off,
  1110. % to get the string to sort the index by.
  1111. {\indexnofonts
  1112. \xdef\temp1{#2 #3}%
  1113. }%
  1114. % Now produce the complete index entry.  We process the index-string again,
  1115. % this time with font commands expanded, to get what to print in the index.
  1116. \edef\temp{%
  1117. \write \csname#1indfile\endcsname{%
  1118. \realbackslash entry {\temp1}{\folio}{#2}{#3}}}%
  1119. \temp }%
  1120. \penalty\count10}}
  1121.  
  1122. % The index entry written in the file actually looks like
  1123. %  \entry {sortstring}{page}{topic}
  1124. % or
  1125. %  \entry {sortstring}{page}{topic}{subtopic}
  1126. % The texindex program reads in these files and writes files
  1127. % containing these kinds of lines:
  1128. %  \initial {c}
  1129. %     before the first topic whose initial is c
  1130. %  \entry {topic}{pagelist}
  1131. %     for a topic that is used without subtopics
  1132. %  \primary {topic}
  1133. %     for the beginning of a topic that is used with subtopics
  1134. %  \secondary {subtopic}{pagelist}
  1135. %     for each subtopic.
  1136.  
  1137. % Define the user-accessible indexing commands 
  1138. % @findex, @vindex, @kindex, @cindex.
  1139.  
  1140. \def\findex {\fnindex}
  1141. \def\kindex {\kyindex}
  1142. \def\cindex {\cpindex}
  1143. \def\vindex {\vrindex}
  1144. \def\tindex {\tpindex}
  1145. \def\pindex {\pgindex}
  1146.  
  1147. \def\cindexsub {\begingroup\obeylines\cindexsub}
  1148. {\obeylines %
  1149. \gdef\cindexsub "#1" #2^^M{\endgroup %
  1150. \dosubind{cp}{#2}{#1}}}
  1151.  
  1152. % Define the macros used in formatting output of the sorted index material.
  1153.  
  1154. % This is what you call to cause a particular index to get printed.
  1155. % Write
  1156. % @unnumbered Function Index
  1157. % @printindex fn
  1158.  
  1159. \def\printindex{\parsearg\doprintindex}
  1160.  
  1161. \def\doprintindex#1{\tex %
  1162. \dobreak \chapheadingskip {10000}
  1163. \catcode`\%=\other\catcode`\&=\other\catcode`\#=\other
  1164. \catcode`\$=\other\catcode`\_=\other
  1165. \catcode`\~=\other
  1166. % The following don't help, since the chars were translated
  1167. % when the raw index was written, and their fonts were discarded
  1168. % due to \indexnofonts.
  1169. %\catcode`\"=\active
  1170. %\catcode`\^=\active
  1171. %\catcode`\_=\active
  1172. %\catcode`\|=\active
  1173. %\catcode`\<=\active
  1174. %\catcode`\>=\active
  1175. \def\indexbackslash{\rawbackslashxx}
  1176. \indexfonts\rm \tolerance=9500 \advance\baselineskip -1pt
  1177. \begindoublecolumns
  1178. \openin 1 \jobname.#1s
  1179. \ifeof 1 
  1180. % \enddoublecolumns gets confused if there is no text in the index,
  1181. % and it loses the chapter title and the aux file entries for the index.
  1182. % The easiest way to prevent this problem is to make sure there is some text.
  1183. (Index is empty)
  1184. \else \closein 1 \input \jobname.#1s
  1185. \fi
  1186. \enddoublecolumns
  1187. \Etex}
  1188.  
  1189. % These macros are used by the sorted index file itself.
  1190. % Change them to control the appearance of the index.
  1191.  
  1192. % Same as \bigskipamount except no shrink.
  1193. % \balancecolumns gets confused if there is any shrink.
  1194. \newskip\initialskipamount \initialskipamount 12pt plus4pt
  1195.  
  1196. \outer\def\initial #1{%
  1197. {\let\tentt=\sectt \let\tt=\sectt \let\sf=\sectt
  1198. \ifdim\lastskip<\initialskipamount
  1199. \removelastskip \penalty-200 \vskip \initialskipamount\fi
  1200. \line{\secbf#1\hfill}\kern 2pt\penalty10000}}
  1201.  
  1202. \outer\def\entry #1#2{
  1203. {\parfillskip=0in \parskip=0in \parindent=0in
  1204. \hangindent=1in \hangafter=1%
  1205. \noindent\hbox{#1}\indexdotfill #2\par
  1206. }}
  1207.  
  1208. % Like \dotfill except takes at least 1 em.
  1209. \def\indexdotfill{\cleaders\hbox{$\mathsurround=0pt \mkern1.5mu . \mkern1.5mu$}\hskip 1em plus 1fill}
  1210.  
  1211. \def\primary #1{\line{#1\hfil}}
  1212.  
  1213. \newskip\secondaryindent \secondaryindent=0.5cm
  1214.  
  1215. \def\secondary #1#2{
  1216. {\parfillskip=0in \parskip=0in
  1217. \hangindent =1in \hangafter=1
  1218. \noindent\hskip\secondaryindent\hbox{#1}\indexdotfill #2\par
  1219. }}
  1220.  
  1221. %% Define two-column mode, which is used in indexes.
  1222. %% Adapted from the TeXBook, page 416
  1223. \catcode `\@=11
  1224.  
  1225. \newbox\partialpage
  1226.  
  1227. \newdimen\doublecolumnhsize  \doublecolumnhsize = 3.11in
  1228. \newdimen\doublecolumnvsize  \doublecolumnvsize = 19.1in
  1229. \newdimen\availdimen@
  1230.  
  1231. \def\begindoublecolumns{\begingroup
  1232.   \output={\global\setbox\partialpage=\vbox{\unvbox255\kern -\topskip \kern \baselineskip}}\eject
  1233.   \output={\doublecolumnout} \hsize=\doublecolumnhsize \vsize=\doublecolumnvsize}
  1234. \def\enddoublecolumns{\output={\balancecolumns}\eject
  1235.   \endgroup \pagegoal=\vsize}
  1236.  
  1237. \def\doublecolumnout{\splittopskip=\topskip \splitmaxdepth=\maxdepth
  1238.   \dimen@=\pageheight \advance\dimen@ by-\ht\partialpage
  1239.   \setbox0=\vsplit255 to\dimen@ \setbox2=\vsplit255 to\dimen@
  1240.   \onepageout\pagesofar \unvbox255 \penalty\outputpenalty}
  1241. \def\pagesofar{\unvbox\partialpage %
  1242.   \hsize=\doublecolumnhsize % have to restore this since output routine
  1243. %          changes it to set cropmarks (P. A. MacKay, 12 Nov. 1986)
  1244.   \wd0=\hsize \wd2=\hsize \hbox to\pagewidth{\box0\hfil\box2}}
  1245. \def\balancecolumns{%
  1246. % Unset the glue.
  1247.   \setbox255=\vbox{\unvbox255}
  1248.   \dimen@=\ht255
  1249.   \advance\dimen@ by\topskip \advance\dimen@ by-\baselineskip
  1250.   \divide\dimen@ by2
  1251.   \availdimen@=\pageheight \advance\availdimen@ by-\ht\partialpage
  1252. % If the remaining data is too big for one page,
  1253. % output one page normally, then work with what remains.
  1254.   \ifdim \dimen@>\availdimen@
  1255.    {
  1256.      \splittopskip=\topskip \splitmaxdepth=\maxdepth
  1257.      \dimen@=\pageheight \advance\dimen@ by-\ht\partialpage
  1258.      \setbox0=\vsplit255 to\dimen@ \setbox2=\vsplit255 to\dimen@
  1259.      \onepageout\pagesofar
  1260.    }
  1261. % Recompute size of what remains, in case we just output some of it.
  1262.   \dimen@=\ht255
  1263.   \advance\dimen@ by\topskip \advance\dimen@ by-\baselineskip
  1264.   \divide\dimen@ by2
  1265.   \fi
  1266.   \setbox0=\vbox{\unvbox255}
  1267.   \splittopskip=\topskip
  1268.   {\vbadness=10000 \loop \global\setbox3=\copy0
  1269.     \global\setbox1=\vsplit3 to\dimen@
  1270.     \ifdim\ht3>\dimen@ \global\advance\dimen@ by1pt \repeat}
  1271.   \setbox0=\vbox to\dimen@{\unvbox1}  \setbox2=\vbox to\dimen@{\unvbox3}
  1272.   \pagesofar}
  1273.  
  1274. \catcode `\@=\other
  1275. \message{sectioning,}
  1276. % Define chapters, sections, etc.
  1277.  
  1278. \newcount \chapno
  1279. \newcount \secno
  1280. \newcount \subsecno
  1281. \newcount \subsubsecno
  1282.  
  1283. % This counter is funny since it counts through charcodes of letters A, B, ...
  1284. \newcount \appendixno  \appendixno = `\@
  1285. \def\appendixletter{\char\the\appendixno}
  1286.  
  1287. \newwrite \contentsfile
  1288. % This is called from \setfilename.
  1289. \def\opencontents{\openout \contentsfile = \jobname.toc}
  1290.  
  1291. % Each @chapter defines this as the name of the chapter.
  1292. % page headings and footings can use it.  @section does likewise
  1293.  
  1294. \def\thischapter{} \def\thissection{}
  1295. \def\seccheck#1{\if \pageno<0 %
  1296. \errmessage{@#1 not allowed after generating table of contents}\fi
  1297. %
  1298. }
  1299.  
  1300. \def\chapternofonts{%
  1301. \let\rawbackslash=\relax%
  1302. \let\frenchspacing=\relax%
  1303. \def\TeX{\realbackslash TeX}
  1304. \def\dots{\realbackslash dots}
  1305. \def\copyright{\realbackslash copyright}
  1306. \def\tt{\realbackslash tt}
  1307. \def\bf{\realbackslash bf }
  1308. \def\w{\realbackslash w}
  1309. \def\less{\realbackslash less}
  1310. \def\gtr{\realbackslash gtr}
  1311. \def\hat{\realbackslash hat}
  1312. \def\char{\realbackslash char}
  1313. \def\tclose##1{\realbackslash tclose {##1}}
  1314. \def\code##1{\realbackslash code {##1}}
  1315. \def\samp##1{\realbackslash samp {##1}}
  1316. \def\r##1{\realbackslash r {##1}}
  1317. \def\b##1{\realbackslash b {##1}}
  1318. \def\key##1{\realbackslash key {##1}}
  1319. \def\file##1{\realbackslash file {##1}}
  1320. \def\kbd##1{\realbackslash kbd {##1}}
  1321. % These are redefined because @smartitalic wouldn't work inside xdef.
  1322. \def\i##1{\realbackslash i {##1}}
  1323. \def\cite##1{\realbackslash cite {##1}}
  1324. \def\var##1{\realbackslash var {##1}}
  1325. \def\emph##1{\realbackslash emph {##1}}
  1326. \def\dfn##1{\realbackslash dfn {##1}}
  1327. }
  1328.  
  1329. \outer\def\chapter{\parsearg\chapterzzz}
  1330. \def\chapterzzz #1{\seccheck{chapter}%
  1331. \secno=0 \subsecno=0 \subsubsecno=0 \global\advance \chapno by 1 \message{Chapter \the\chapno}%
  1332. \chapmacro {#1}{\the\chapno}%
  1333. \gdef\thissection{#1}%
  1334. \gdef\thischaptername{#1}%
  1335. % We don't substitute the actual chapter name into \thischapter
  1336. % because we don't want its macros evaluated now.
  1337. \xdef\thischapter{Chapter \the\chapno: \noexpand\thischaptername}%
  1338. {\chapternofonts%
  1339. \edef\temp{{\realbackslash chapentry {#1}{\the\chapno}{\noexpand\folio}}}%
  1340. \escapechar=`\\%
  1341. \write \contentsfile \temp  %
  1342. \donoderef %
  1343. }}
  1344.  
  1345. \outer\def\appendix{\parsearg\appendixzzz}
  1346. \def\appendixzzz #1{\seccheck{appendix}%
  1347. \secno=0 \subsecno=0 \subsubsecno=0 \global\advance \appendixno by 1 \message{Appendix \appendixletter}%
  1348. \chapmacro {#1}{Appendix \appendixletter}%
  1349. \gdef\thissection{#1}%
  1350. \gdef\thischaptername{#1}%
  1351. \xdef\thischapter{Appendix \appendixletter: \noexpand\thischaptername}%
  1352. {\chapternofonts%
  1353. \edef\temp{{\realbackslash chapentry {#1}{Appendix \appendixletter}{\noexpand\folio}}}%
  1354. \escapechar=`\\%
  1355. \write \contentsfile \temp  %
  1356. \appendixnoderef %
  1357. }}
  1358.  
  1359. \outer\def\top{\parsearg\unnumberedzzz}
  1360. \outer\def\unnumbered{\parsearg\unnumberedzzz}
  1361. \def\unnumberedzzz #1{\seccheck{unnumbered}%
  1362. \secno=0 \subsecno=0 \subsubsecno=0 \message{(#1)}
  1363. \unnumbchapmacro {#1}%
  1364. \gdef\thischapter{#1}\gdef\thissection{#1}%
  1365. {\chapternofonts%
  1366. \edef\temp{{\realbackslash unnumbchapentry {#1}{\noexpand\folio}}}%
  1367. \escapechar=`\\%
  1368. \write \contentsfile \temp  %
  1369. \unnumbnoderef %
  1370. }}
  1371.  
  1372. \outer\def\section{\parsearg\sectionzzz}
  1373. \def\sectionzzz #1{\seccheck{section}%
  1374. \subsecno=0 \subsubsecno=0 \global\advance \secno by 1 %
  1375. \gdef\thissection{#1}\secheading {#1}{\the\chapno}{\the\secno}%
  1376. {\chapternofonts%
  1377. \edef\temp{{\realbackslash secentry %
  1378. {#1}{\the\chapno}{\the\secno}{\noexpand\folio}}}%
  1379. \escapechar=`\\%
  1380. \write \contentsfile \temp %
  1381. \donoderef %
  1382. \penalty 10000 %
  1383. }}
  1384.  
  1385. \outer\def\appendixsection{\parsearg\appendixsectionzzz}
  1386. \outer\def\appendixsec{\parsearg\appendixsectionzzz}
  1387. \def\appendixsectionzzz #1{\seccheck{appendixsection}%
  1388. \subsecno=0 \subsubsecno=0 \global\advance \secno by 1 %
  1389. \gdef\thissection{#1}\secheading {#1}{\appendixletter}{\the\secno}%
  1390. {\chapternofonts%
  1391. \edef\temp{{\realbackslash secentry %
  1392. {#1}{\appendixletter}{\the\secno}{\noexpand\folio}}}%
  1393. \escapechar=`\\%
  1394. \write \contentsfile \temp %
  1395. \appendixnoderef %
  1396. \penalty 10000 %
  1397. }}
  1398.  
  1399. \outer\def\unnumberedsec{\parsearg\unnumberedseczzz}
  1400. \def\unnumberedseczzz #1{\seccheck{unnumberedsec}%
  1401. \plainsecheading {#1}\gdef\thissection{#1}%
  1402. {\chapternofonts%
  1403. \edef\temp{{\realbackslash unnumbsecentry{#1}{\noexpand\folio}}}%
  1404. \escapechar=`\\%
  1405. \write \contentsfile \temp %
  1406. \unnumbnoderef %
  1407. \penalty 10000 %
  1408. }}
  1409.  
  1410. \outer\def\subsection{\parsearg\subsectionzzz}
  1411. \def\subsectionzzz #1{\seccheck{subsection}%
  1412. \gdef\thissection{#1}\subsubsecno=0 \global\advance \subsecno by 1 %
  1413. \subsecheading {#1}{\the\chapno}{\the\secno}{\the\subsecno}%
  1414. {\chapternofonts%
  1415. \edef\temp{{\realbackslash subsecentry %
  1416. {#1}{\the\chapno}{\the\secno}{\the\subsecno}{\noexpand\folio}}}%
  1417. \escapechar=`\\%
  1418. \write \contentsfile \temp %
  1419. \donoderef %
  1420. \penalty 10000 %
  1421. }}
  1422.  
  1423. \outer\def\appendixsubsec{\parsearg\appendixsubseczzz}
  1424. \def\appendixsubseczzz #1{\seccheck{appendixsubsec}%
  1425. \gdef\thissection{#1}\subsubsecno=0 \global\advance \subsecno by 1 %
  1426. \subsecheading {#1}{\appendixletter}{\the\secno}{\the\subsecno}%
  1427. {\chapternofonts%
  1428. \edef\temp{{\realbackslash subsecentry %
  1429. {#1}{\appendixletter}{\the\secno}{\the\subsecno}{\noexpand\folio}}}%
  1430. \escapechar=`\\%
  1431. \write \contentsfile \temp %
  1432. \appendixnoderef %
  1433. \penalty 10000 %
  1434. }}
  1435.  
  1436. \outer\def\unnumberedsubsec{\parsearg\unnumberedsubseczzz}
  1437. \def\unnumberedsubseczzz #1{\seccheck{unnumberedsubsec}%
  1438. \plainsecheading {#1}\gdef\thissection{#1}%
  1439. {\chapternofonts%
  1440. \edef\temp{{\realbackslash unnumbsubsecentry{#1}{\noexpand\folio}}}%
  1441. \escapechar=`\\%
  1442. \write \contentsfile \temp %
  1443. \unnumbnoderef %
  1444. \penalty 10000 %
  1445. }}
  1446.  
  1447. \outer\def\subsubsection{\parsearg\subsubsectionzzz}
  1448. \def\subsubsectionzzz #1{\seccheck{subsubsection}%
  1449. \gdef\thissection{#1}\global\advance \subsubsecno by 1 %
  1450. \subsubsecheading {#1}{\the\chapno}{\the\secno}{\the\subsecno}{\the\subsubsecno}%
  1451. {\chapternofonts%
  1452. \edef\temp{{\realbackslash subsubsecentry %
  1453. {#1}{\the\chapno}{\the\secno}{\the\subsecno}{\the\subsubsecno}{\noexpand\folio}}}%\
  1454. \escapechar=`\\%
  1455. \write \contentsfile \temp %
  1456. \donoderef %
  1457. \penalty 10000 %
  1458. }}
  1459.  
  1460. \outer\def\appendixsubsubsec{\parsearg\appendixsubsubseczzz}
  1461. \def\appendixsubsubseczzz #1{\seccheck{appendixsubsubsec}%
  1462. \gdef\thissection{#1}\global\advance \subsubsecno by 1 %
  1463. \subsubsecheading {#1}{\appendixletter}{\the\secno}{\the\subsecno}{\the\subsubsecno}%
  1464. {\chapternofonts%
  1465. \edef\temp{{\realbackslash subsubsecentry{#1}%
  1466. {\appendixletter}{\the\secno}{\the\subsecno}{\the\subsubsecno}{\noexpand\folio}}}%\
  1467. \escapechar=`\\%
  1468. \write \contentsfile \temp %
  1469. \appendixnoderef %
  1470. \penalty 10000 %
  1471. }}
  1472.  
  1473. \outer\def\unnumberedsubsubsec{\parsearg\unnumberedsubsubseczzz}
  1474. \def\unnumberedsubsubseczzz #1{\seccheck{unnumberedsubsubsec}%
  1475. \plainsecheading {#1}\gdef\thissection{#1}%
  1476. {\chapternofonts%
  1477. \edef\temp{{\realbackslash unnumbsubsubsecentry{#1}{\noexpand\folio}}}%
  1478. \escapechar=`\\%
  1479. \write \contentsfile \temp %
  1480. \unnumbnoderef %
  1481. \penalty 10000 %
  1482. }}
  1483.  
  1484. % These are variants which are not "outer", so they can appear in @ifinfo.
  1485. \def\infotop{\parsearg\unnumberedzzz}
  1486. \def\infounnumbered{\parsearg\unnumberedzzz}
  1487. \def\infounnumberedsec{\parsearg\unnumberedseczzz}
  1488. \def\infounnumberedsubsec{\parsearg\unnumberedsubseczzz}
  1489. \def\infounnumberedsubsubsec{\parsearg\unnumberedsubsubseczzz}
  1490.  
  1491. \def\infoappendix{\parsearg\appendixzzz}
  1492. \def\infoappendixsec{\parsearg\appendixseczzz}
  1493. \def\infoappendixsubsec{\parsearg\appendixsubseczzz}
  1494. \def\infoappendixsubsubsec{\parsearg\appendixsubsubseczzz}
  1495.  
  1496. \def\infochapter{\parsearg\chapterzzz}
  1497. \def\infosection{\parsearg\sectionzzz}
  1498. \def\infosubsection{\parsearg\subsectionzzz}
  1499. \def\infosubsubsection{\parsearg\subsubsectionzzz}
  1500.  
  1501. % Define @majorheading, @heading and @subheading
  1502.  
  1503. \def\majorheading{\parsearg\majorheadingzzz}
  1504. \def\majorheadingzzz #1{%
  1505. {\advance\chapheadingskip by 10pt \chapbreak }%
  1506. {\chapfonts \line{\rm #1\hfill}}\bigskip \par\penalty 200}
  1507.  
  1508. \def\chapheading{\parsearg\chapheadingzzz}
  1509. \def\chapheadingzzz #1{\chapbreak %
  1510. {\chapfonts \line{\rm #1\hfill}}\bigskip \par\penalty 200}
  1511.  
  1512. \def\heading{\parsearg\secheadingi}
  1513.  
  1514. \def\subheading{\parsearg\subsecheadingi}
  1515.  
  1516. \def\subsubheading{\parsearg\subsubsecheadingi}
  1517.  
  1518. % These macros generate a chapter, section, etc. heading only
  1519. % (including whitespace, linebreaking, etc. around it),
  1520. % given all the information in convenient, parsed form.
  1521.  
  1522. %%% Args are the skip and penalty (usually negative)
  1523. \def\dobreak#1#2{\par\ifdim\lastskip<#1\removelastskip\penalty#2\vskip#1\fi}
  1524.  
  1525. \def\setchapterstyle #1 {\csname CHAPF#1\endcsname}
  1526.  
  1527. %%% Define plain chapter starts, and page on/off switching for it
  1528. % Parameter controlling skip before chapter headings (if needed)
  1529.  
  1530. \newskip \chapheadingskip \chapheadingskip = 30pt plus 8pt minus 4pt
  1531.  
  1532. \def\chapbreak{\dobreak \chapheadingskip {-4000}}
  1533. \def\chappager{\par\vfill\supereject}
  1534. \def\chapoddpage{\chappager \ifodd\pageno \else \hbox to 0pt{} \chappager\fi}
  1535.  
  1536. \def\setchapternewpage #1 {\csname CHAPPAG#1\endcsname}
  1537.  
  1538. \def\CHAPPAGoff{
  1539. \global\let\pchapsepmacro=\chapbreak
  1540. \global\let\pagealignmacro=\chappager}
  1541.  
  1542. \def\CHAPPAGon{
  1543. \global\let\pchapsepmacro=\chappager
  1544. \global\let\pagealignmacro=\chappager
  1545. \global\def\HEADINGSon{\HEADINGSsingle}}
  1546.  
  1547. \def\CHAPPAGodd{
  1548. \global\let\pchapsepmacro=\chapoddpage
  1549. \global\let\pagealignmacro=\chapoddpage
  1550. \global\def\HEADINGSon{\HEADINGSdouble}}
  1551.  
  1552. \CHAPPAGon
  1553.  
  1554. \def\CHAPFplain{
  1555. \global\let\chapmacro=\chfplain
  1556. \global\let\unnumbchapmacro=\unnchfplain}
  1557.  
  1558. \def\chfplain #1#2{%
  1559.   \pchapsepmacro
  1560.   {%
  1561.     \chapfonts
  1562.     \leftline{\rm #2\enspace #1}%
  1563.   }%
  1564.   \bigskip
  1565.   \penalty5000
  1566. }
  1567.  
  1568. \def\unnchfplain #1{%
  1569. \pchapsepmacro %
  1570. {\chapfonts \line{\rm #1\hfill}}\bigskip \par\penalty 10000 %
  1571. }
  1572. \CHAPFplain % The default
  1573.  
  1574. \def\unnchfopen #1{%
  1575. \chapoddpage {\chapfonts \line{\rm #1\hfill}}\bigskip \par\penalty 10000 %
  1576. }
  1577.  
  1578. \def\chfopen #1#2{\chapoddpage {\chapfonts
  1579. \vbox to 3in{\vfil \hbox to\hsize{\hfil #2} \hbox to\hsize{\hfil #1} \vfil}}%
  1580. \par\penalty 5000 %
  1581. }
  1582.  
  1583. \def\CHAPFopen{
  1584. \global\let\chapmacro=\chfopen
  1585. \global\let\unnumbchapmacro=\unnchfopen}
  1586.  
  1587. % Parameter controlling skip before section headings.
  1588.  
  1589. \newskip \subsecheadingskip  \subsecheadingskip = 17pt plus 8pt minus 4pt
  1590. \def\subsecheadingbreak{\dobreak \subsecheadingskip {-500}}
  1591.  
  1592. \newskip \secheadingskip  \secheadingskip = 21pt plus 8pt minus 4pt
  1593. \def\secheadingbreak{\dobreak \secheadingskip {-1000}}
  1594.  
  1595.  
  1596. % Section fonts are the base font at magstep2, which produces
  1597. % a size a bit more than 14 points in the default situation.    
  1598.  
  1599. \def\secheading #1#2#3{\secheadingi {#2.#3\enspace #1}}
  1600. \def\plainsecheading #1{\secheadingi {#1}}
  1601. \def\secheadingi #1{{\advance \secheadingskip by \parskip %
  1602. \secheadingbreak}%
  1603. {\secfonts \line{\rm #1\hfill}}%
  1604. \ifdim \parskip<10pt \kern 10pt\kern -\parskip\fi \penalty 10000 }
  1605.  
  1606.  
  1607. % Subsection fonts are the base font at magstep1, 
  1608. % which produces a size of 12 points.
  1609.  
  1610. \def\subsecheading #1#2#3#4{\subsecheadingi {#2.#3.#4\enspace #1}}
  1611. \def\subsecheadingi #1{{\advance \subsecheadingskip by \parskip %
  1612. \subsecheadingbreak}%
  1613. {\subsecfonts \line{\rm #1\hfill}}%
  1614. \ifdim \parskip<10pt \kern 10pt\kern -\parskip\fi \penalty 10000 }
  1615.  
  1616. \def\subsubsecfonts{\subsecfonts} % Maybe this should change:
  1617.                   % Perhaps make sssec fonts scaled
  1618.                   % magstep half
  1619. \def\subsubsecheading #1#2#3#4#5{\subsubsecheadingi {#2.#3.#4.#5\enspace #1}}
  1620. \def\subsubsecheadingi #1{{\advance \subsecheadingskip by \parskip %
  1621. \subsecheadingbreak}%
  1622. {\subsubsecfonts \line{\rm #1\hfill}}%
  1623. \ifdim \parskip<10pt \kern 10pt\kern -\parskip\fi \penalty 10000}
  1624.  
  1625.  
  1626. \message{toc printing,}
  1627.  
  1628. % Finish up the main text and prepare to read what we've written
  1629. % to \contentsfile.
  1630.  
  1631. \def\startcontents#1{%
  1632.    \ifnum \pageno>0
  1633.       \pagealignmacro
  1634.       \immediate\closeout \contentsfile
  1635.       \pageno = -1        % Request roman numbered pages.
  1636.    \fi
  1637.    % Don't need to put `Contents' or `Short Contents' in the headline. 
  1638.    % It is abundantly clear what they are.
  1639.    \unnumbchapmacro{#1}\def\thischapter{}%
  1640.    \begingroup           % Set up to handle contents files properly.
  1641.       \catcode`\\=0  \catcode`\{=1  \catcode`\}=2  \catcode`\@=11
  1642.       \raggedbottom             % Worry more about breakpoints than the bottom.
  1643.       \advance\hsize by -1in    % Don't use the full line length.
  1644. }
  1645.  
  1646.   
  1647. % Normal (long) toc.
  1648. \outer\def\contents{%
  1649.    \startcontents{Table of Contents}%
  1650.       \input \jobname.toc
  1651.    \endgroup
  1652.    \vfill \eject
  1653. }
  1654.  
  1655. % And just the chapters.
  1656. \outer\def\summarycontents{%
  1657.    \startcontents{Short Contents}%
  1658.       %
  1659.       \let\chapentry = \shortchapentry
  1660.       \let\unnumbchapentry = \shortunnumberedentry
  1661.       % We want a true roman here for the page numbers.
  1662.       \secfonts
  1663.       \let\rm=\shortcontrm \let\bf=\shortcontbf \let\sl=\shortcontsl
  1664.       \rm
  1665.       \advance\baselineskip by 1pt % Open it up a little.
  1666.       \def\secentry ##1##2##3##4{}
  1667.       \def\unnumbsecentry ##1##2{}
  1668.       \def\subsecentry ##1##2##3##4##5{}
  1669.       \def\unnumbsubsecentry ##1##2{}
  1670.       \def\subsubsecentry ##1##2##3##4##5##6{}
  1671.       \def\unnumbsubsubsecentry ##1##2{}
  1672.       \input \jobname.toc
  1673.    \endgroup
  1674.    \vfill \eject
  1675. }
  1676. \let\shortcontents = \summarycontents
  1677.  
  1678. % These macros generate individual entries in the table of contents.
  1679. % The first argument is the chapter or section name.
  1680. % The last argument is the page number.
  1681. % The arguments in between are the chapter number, section number, ...
  1682.  
  1683. % Chapter-level things, for both the long and short contents.
  1684. \def\chapentry#1#2#3{\dochapentry{#2\labelspace#1}{#3}}
  1685. \def\shortchapentry#1#2#3{%
  1686.    \line{{#2\labelspace #1}\dotfill\doshortpageno{#3}}%
  1687. }
  1688.  
  1689. \def\unnumbchapentry#1#2{\dochapentry{#1}{#2}}
  1690. \def\shortunnumberedentry#1#2{%
  1691.    \line{#1\dotfill\doshortpageno{#2}}%
  1692. }
  1693.  
  1694. % Sections.
  1695. \def\secentry#1#2#3#4{\dosecentry{#2.#3\labelspace#1}{#4}}
  1696. \def\unnumbsecentry#1#2{\dosecentry{#1}{#2}}
  1697.  
  1698. % Subsections.
  1699. \def\subsecentry#1#2#3#4#5{\dosubsecentry{#2.#3.#4\labelspace#1}{#5}}
  1700. \def\unnumbsubsecentry#1#2{\dosubsecentry{#1}{#2}}
  1701.  
  1702. % And subsubsections.
  1703. \def\subsubsecentry#1#2#3#4#5#6{\dosubsubsecentry{#2.#3.#4.#5\labelspace#1}{#6}}
  1704. \def\unnumbsubsubsecentry#1#2{\dosubsubsecentry{#1}{#2}}
  1705.  
  1706.  
  1707. % This parameter controls the indentation of the various levels.
  1708. \newdimen\tocindent \tocindent = 3pc
  1709.  
  1710. % Now for the actual typesetting. In all these, #1 is the text and #2 is the 
  1711. % page number.
  1712. %
  1713. % If the toc has to be broken over pages, we would want to be at chapters 
  1714. % if at all possible; hence the \penalty.
  1715. \def\dochapentry#1#2{%
  1716.    \penalty-300 \vskip\baselineskip
  1717.    \line{\chapentryfonts #1\dotfill \dopageno{#2}}%
  1718.    \nobreak\vskip .25\baselineskip
  1719. }
  1720.  
  1721. \def\dosecentry#1#2{%
  1722.    \line{\secentryfonts \hskip\tocindent #1\dotfill \dopageno{#2}}%
  1723. }
  1724.  
  1725. \def\dosubsecentry#1#2{%
  1726.    \line{\subsecentryfonts \hskip2\tocindent #1\dotfill \dopageno{#2}}%
  1727. }
  1728.  
  1729. \def\dosubsubsecentry#1#2{%
  1730.    \line{\subsubsecentryfonts \hskip3\tocindent #1\dotfill \dopageno{#2}}%
  1731. }
  1732.  
  1733. % Space between chapter (or whatever) number and the title.
  1734. \def\labelspace{\hskip1em \relax}
  1735.  
  1736. \def\dopageno#1{{\rm #1}}
  1737. \def\doshortpageno#1{{\rm #1}}
  1738.  
  1739. \def\chapentryfonts{\secfonts \rm}
  1740. \def\secentryfonts{\textfonts}
  1741. \let\subsecentryfonts = \textfonts
  1742. \let\subsubsecentryfonts = \textfonts
  1743.  
  1744.  
  1745. \message{environments,}
  1746.  
  1747. % Since these characters are used in examples, it should be an even number of 
  1748. % \tt widths. Each \tt character is 1en, so two makes it 1em.
  1749. % Furthermore, these definitions must come after we define our fonts.
  1750. \newbox\dblarrowbox    \newbox\longdblarrowbox
  1751. \newbox\pushcharbox    \newbox\bullbox
  1752. \newbox\equivbox       \newbox\errorbox
  1753.  
  1754. \let\ptexequiv = \equiv
  1755.  
  1756. {\tentt
  1757. \global\setbox\dblarrowbox = \hbox to 1em{\hfil$\Rightarrow$\hfil}
  1758. \global\setbox\longdblarrowbox = \hbox to 1em{\hfil$\mapsto$\hfil}
  1759. \global\setbox\pushcharbox = \hbox to 1em{\hfil$\dashv$\hfil}
  1760. \global\setbox\equivbox = \hbox to 1em{\hfil$\ptexequiv$\hfil}
  1761. % Adapted from the manmac format (p.420 of TeXbook)
  1762. \global\setbox\bullbox = \hbox to 1em{\kern.15em\vrule height .75ex width .85ex
  1763.                                       depth .1ex\hfil}
  1764. }
  1765.  
  1766. \def\point{$\star$}
  1767.  
  1768. \def\result{\leavevmode\raise.15ex\copy\dblarrowbox}
  1769. \def\expansion{\leavevmode\raise.1ex\copy\longdblarrowbox}
  1770. \def\print{\leavevmode\lower.1ex\copy\pushcharbox}
  1771.  
  1772. \def\equiv{\leavevmode\lower.1ex\copy\equivbox}
  1773.  
  1774. % Does anyone really want this?
  1775. % \def\bull{\leavevmode\copy\bullbox}
  1776.  
  1777. % Adapted from the TeXbook's \boxit.
  1778. {\tentt \global\dimen0 = 3em}% Width of the box.
  1779. \dimen2 = .55pt % Thickness of rules
  1780. % The text. (`r' is open on the right, `e' somewhat less so on the left.)
  1781. \setbox0 = \hbox{\kern-.75pt \tensf error\kern-1.5pt}
  1782.  
  1783. \global\setbox\errorbox=\hbox to \dimen0{\hfil
  1784.    \hsize = \dimen0 \advance\hsize by -5.8pt % Space to left+right.
  1785.    \advance\hsize by -2\dimen2 % Rules.
  1786.    \vbox{
  1787.       \hrule height\dimen2
  1788.       \hbox{\vrule width\dimen2 \kern3pt          % Space to left of text.
  1789.          \vtop{\kern2.4pt \box0 \kern2.4pt}% Space above/below.
  1790.          \kern3pt\vrule width\dimen2}% Space to right.
  1791.       \hrule height\dimen2}
  1792.     \hfil}
  1793.  
  1794. % The @error{} command.
  1795. \def\error{\leavevmode\lower.7ex\copy\errorbox}
  1796.  
  1797. % @tex ... @end tex    escapes into raw Tex temporarily.
  1798. % One exception: @ is still an escape character, so that @end tex works.
  1799. % But \@ or @@ will get a plain tex @ character.
  1800.  
  1801. \def\tex{\begingroup
  1802. \catcode `\\=0 \catcode `\{=1 \catcode `\}=2
  1803. \catcode `\$=3 \catcode `\&=4 \catcode `\#=6
  1804. \catcode `\^=7 \catcode `\_=8 \catcode `\~=13 \let~=\tie
  1805. \catcode `\%=14
  1806. \catcode 43=12
  1807. \catcode`\"=12
  1808. \catcode`\==12
  1809. \catcode`\|=12
  1810. \catcode`\<=12
  1811. \catcode`\>=12
  1812. \escapechar=`\\
  1813. %
  1814. \let\{=\ptexlbrace
  1815. \let\}=\ptexrbrace
  1816. \let\.=\ptexdot
  1817. \let\*=\ptexstar
  1818. \let\dots=\ptexdots
  1819. \def\@={@}%
  1820. \let\bullet=\ptexbullet
  1821. \let\b=\ptexb \let\c=\ptexc \let\i=\ptexi \let\t=\ptext \let\l=\ptexl
  1822. \let\L=\ptexL
  1823. %
  1824. \let\Etex=\endgroup}
  1825.  
  1826. % Define @lisp ... @endlisp.
  1827. % @lisp does a \begingroup so it can rebind things,
  1828. % including the definition of @endlisp (which normally is erroneous).
  1829.  
  1830. % Amount to narrow the margins by for @lisp.
  1831. \newskip\lispnarrowing \lispnarrowing=0.4in
  1832.  
  1833. % This is the definition that ^M gets inside @lisp
  1834. % phr: changed space to \null, to avoid overfull hbox problems.
  1835. {\obeyspaces%
  1836. \gdef\lisppar{\null\endgraf}}
  1837.  
  1838. % Cause \obeyspaces to make each Space cause a word-separation
  1839. % rather than the default which is that it acts punctuation.
  1840. % This is because space in tt font looks funny.
  1841. {\obeyspaces %
  1842. \gdef\sepspaces{\def {\ }}}
  1843.  
  1844. \newskip\aboveenvskipamount \aboveenvskipamount= 0pt
  1845. \def\aboveenvbreak{{\advance\aboveenvskipamount by \parskip
  1846. \endgraf \ifdim\lastskip<\aboveenvskipamount
  1847. \removelastskip \penalty-50 \vskip\aboveenvskipamount \fi}}
  1848.  
  1849. \def\afterenvbreak{\endgraf \ifdim\lastskip<\aboveenvskipamount
  1850. \removelastskip \penalty-50 \vskip\aboveenvskipamount \fi}
  1851.  
  1852. \def\lisp{\aboveenvbreak\begingroup\inENV %This group ends at the end of the @lisp body
  1853. \hfuzz=12truept % Don't be fussy
  1854. % Make spaces be word-separators rather than space tokens.
  1855. \sepspaces %
  1856. % Single space lines
  1857. \singlespace %
  1858. % The following causes blank lines not to be ignored
  1859. % by adding a space to the end of each line.
  1860. \let\par=\lisppar
  1861. \def\Elisp{\endgroup\afterenvbreak}%
  1862. \parskip=0pt
  1863. \advance \leftskip by \lispnarrowing
  1864. \parindent=0pt
  1865. \let\exdent=\internalexdent
  1866. \obeyspaces \obeylines \tt \rawbackslash
  1867. \def\next##1{}\next}
  1868.  
  1869.  
  1870. \let\example=\lisp
  1871. \def\Eexample{\Elisp}
  1872.  
  1873. \let\smallexample=\lisp
  1874. \def\Esmallexample{\Elisp}
  1875.  
  1876. % Macro for 9 pt. examples, necessary to print with 5" lines.
  1877. % From Pavel@xerox.  This is not really used unless the
  1878. % @smallbook command is given.
  1879.  
  1880. \def\smalllispx{\aboveenvbreak\begingroup\inENV
  1881. %            This group ends at the end of the @lisp body
  1882. \hfuzz=12truept % Don't be fussy
  1883. % Make spaces be word-separators rather than space tokens.
  1884. \sepspaces %
  1885. % Single space lines
  1886. \singlespace %
  1887. % The following causes blank lines not to be ignored
  1888. % by adding a space to the end of each line.
  1889. \let\par=\lisppar
  1890. \def\Esmalllisp{\endgroup\afterenvbreak}%
  1891. \parskip=0pt
  1892. \advance \leftskip by \lispnarrowing
  1893. \parindent=0pt
  1894. \let\exdent=\internalexdent
  1895. \obeyspaces \obeylines \ninett \indexfonts \rawbackslash
  1896. \def\next##1{}\next}
  1897.  
  1898. % This is @display; same as @lisp except use roman font.
  1899.  
  1900. \def\display{\begingroup\inENV %This group ends at the end of the @display body
  1901. \aboveenvbreak
  1902. % Make spaces be word-separators rather than space tokens.
  1903. \sepspaces %
  1904. % Single space lines
  1905. \singlespace %
  1906. % The following causes blank lines not to be ignored
  1907. % by adding a space to the end of each line.
  1908. \let\par=\lisppar
  1909. \def\Edisplay{\endgroup\afterenvbreak}%
  1910. \parskip=0pt
  1911. \advance \leftskip by \lispnarrowing
  1912. \parindent=0pt
  1913. \let\exdent=\internalexdent
  1914. \obeyspaces \obeylines
  1915. \def\next##1{}\next}
  1916.  
  1917. % This is @format; same as @lisp except use roman font and don't narrow margins
  1918.  
  1919. \def\format{\begingroup\inENV %This group ends at the end of the @format body
  1920. \aboveenvbreak
  1921. % Make spaces be word-separators rather than space tokens.
  1922. \sepspaces %
  1923. \singlespace %
  1924. % The following causes blank lines not to be ignored
  1925. % by adding a space to the end of each line.
  1926. \let\par=\lisppar
  1927. \def\Eformat{\endgroup\afterenvbreak}
  1928. \parskip=0pt \parindent=0pt
  1929. \obeyspaces \obeylines
  1930. \def\next##1{}\next}
  1931.  
  1932. % @flushleft and @flushright
  1933.  
  1934. \def\flushleft{\begingroup\inENV %This group ends at the end of the @format body
  1935. \aboveenvbreak
  1936. % Make spaces be word-separators rather than space tokens.
  1937. \sepspaces %
  1938. % The following causes blank lines not to be ignored
  1939. % by adding a space to the end of each line.
  1940. % This also causes @ to work when the directive name
  1941. % is terminated by end of line.
  1942. \let\par=\lisppar
  1943. \def\Eflushleft{\endgroup\afterenvbreak}%
  1944. \parskip=0pt \parindent=0pt
  1945. \obeyspaces \obeylines
  1946. \def\next##1{}\next}
  1947.  
  1948. \def\flushright{\begingroup\inENV %This group ends at the end of the @format body
  1949. \aboveenvbreak
  1950. % Make spaces be word-separators rather than space tokens.
  1951. \sepspaces %
  1952. % The following causes blank lines not to be ignored
  1953. % by adding a space to the end of each line.
  1954. % This also causes @ to work when the directive name
  1955. % is terminated by end of line.
  1956. \let\par=\lisppar
  1957. \def\Eflushright{\endgroup\afterenvbreak}%
  1958. \parskip=0pt \parindent=0pt
  1959. \advance \leftskip by 0pt plus 1fill
  1960. \obeyspaces \obeylines
  1961. \def\next##1{}\next}
  1962.  
  1963. % @quotation - narrow the margins.
  1964.  
  1965. \def\quotation{\begingroup\inENV %This group ends at the end of the @quotation body
  1966. {\parskip=0pt  % because we will skip by \parskip too, later
  1967. \aboveenvbreak}%
  1968. \singlespace
  1969. \parindent=0pt
  1970. \def\Equotation{\par\endgroup\afterenvbreak}%
  1971. \advance \rightskip by \lispnarrowing 
  1972. \advance \leftskip by \lispnarrowing}
  1973.  
  1974. \message{defuns,}
  1975. % Define formatter for defuns
  1976. % First, allow user to change definition object font (\df) internally
  1977. \def\setdeffont #1 {\csname DEF#1\endcsname}
  1978.  
  1979. \newskip\defbodyindent \defbodyindent=.4in
  1980. \newskip\defargsindent \defargsindent=50pt
  1981. \newskip\deftypemargin \deftypemargin=12pt
  1982. \newskip\deflastargmargin \deflastargmargin=18pt
  1983.  
  1984. \newcount\parencount
  1985. % define \functionparens, which makes ( and ) and & do special things.
  1986. % \functionparens affects the group it is contained in.
  1987. \def\activeparens{%
  1988. \catcode`\(=\active \catcode`\)=\active \catcode`\&=\active
  1989. \catcode`\[=\active \catcode`\]=\active}
  1990. {\activeparens % Now, smart parens don't turn on until &foo (see \amprm)
  1991. \gdef\functionparens{\boldbrax\let&=\amprm\parencount=0 }
  1992. \gdef\boldbrax{\let(=\opnr\let)=\clnr\let[=\lbrb\let]=\rbrb}
  1993.  
  1994. % Definitions of (, ) and & used in args for functions.
  1995. % This is the definition of ( outside of all parentheses.
  1996. \gdef\oprm#1 {{\rm\char`\(}#1 \bf \let(=\opnested %
  1997. \global\advance\parencount by 1 }
  1998. %
  1999. % This is the definition of ( when already inside a level of parens.
  2000. \gdef\opnested{\char`\(\global\advance\parencount by 1 }
  2001. %
  2002. \gdef\clrm{% Print a paren in roman if it is taking us back to depth of 0.
  2003. % also in that case restore the outer-level definition of (.
  2004. \ifnum \parencount=1 {\rm \char `\)}\sl \let(=\oprm \else \char `\) \fi
  2005. \global\advance \parencount by -1 }
  2006. % If we encounter &foo, then turn on ()-hacking afterwards
  2007. \gdef\amprm#1 {{\rm\}\let(=\oprm \let)=\clrm\ }
  2008. %
  2009. \gdef\normalparens{\boldbrax\let&=\ampnr}
  2010. } % End of definition inside \activeparens
  2011. %% These parens (in \boldbrax) actually are a little bolder than the
  2012. %% contained text.  This is especially needed for [ and ]
  2013. \def\opnr{{\sf\char`\(}} \def\clnr{{\sf\char`\)}} \def\ampnr{\&}
  2014. \def\lbrb{{\bf\char`\[}} \def\rbrb{{\bf\char`\]}}
  2015.  
  2016. % First, defname, which formats the header line itself.
  2017. % #1 should be the function name.
  2018. % #2 should be the type of definition, such as "Function".
  2019.  
  2020. \def\defname #1#2{%
  2021. % Get the values of \leftskip and \rightskip as they were
  2022. % outside the @def...
  2023. \dimen2=\leftskip
  2024. \advance\dimen2 by -\defbodyindent
  2025. \dimen3=\rightskip
  2026. \advance\dimen3 by -\defbodyindent
  2027. \noindent        %
  2028. \setbox0=\hbox{\hskip \deflastargmargin{\rm #2}\hskip \deftypemargin}%
  2029. \dimen0=\hsize \advance \dimen0 by -\wd0 % compute size for first line
  2030. \dimen1=\hsize \advance \dimen1 by -\defargsindent %size for continuations
  2031. \parshape 2 0in \dimen0 \defargsindent \dimen1     %
  2032. % Now output arg 2 ("Function" or some such)
  2033. % ending at \deftypemargin from the right margin,
  2034. % but stuck inside a box of width 0 so it does not interfere with linebreaking
  2035. {% Adjust \hsize to exclude the ambient margins,
  2036. % so that \rightline will obey them.
  2037. \advance \hsize by -\dimen2 \advance \hsize by -\dimen3
  2038. \rlap{\rightline{{\rm #2}\hskip \deftypemargin}}}%
  2039. \tolerance=10000 \hbadness=10000    % Make all lines underfull and no complaints
  2040. {\df #1}\enskip        % Generate function name
  2041. }
  2042.  
  2043. % Actually process the body of a definition
  2044. % #1 should be the terminating control sequence, such as \Edefun.
  2045. % #2 should be the "another name" control sequence, such as \defunx.
  2046. % #3 should be the control sequence that actually processes the header,
  2047. %    such as \defunheader.
  2048.  
  2049. \def\defparsebody #1#2#3{\begingroup\inENV% Environment for definitionbody
  2050. \medbreak %
  2051. % Define the end token that this defining construct specifies
  2052. % so that it will exit this group.
  2053. \def#1{\endgraf\endgroup\medbreak}%
  2054. \def#2{\begingroup\obeylines\activeparens\spacesplit#3}%
  2055. \parindent=0in
  2056. \advance\leftskip by \defbodyindent \advance \rightskip by \defbodyindent
  2057. \begingroup %
  2058. \catcode 61=\active %
  2059. \obeylines\activeparens\spacesplit#3}
  2060.  
  2061. \def\defmethparsebody #1#2#3#4 {\begingroup\inENV %
  2062. \medbreak %
  2063. % Define the end token that this defining construct specifies
  2064. % so that it will exit this group.
  2065. \def#1{\endgraf\endgroup\medbreak}%
  2066. \def#2##1 {\begingroup\obeylines\activeparens\spacesplit{#3{##1}}}%
  2067. \parindent=0in
  2068. \advance\leftskip by \defbodyindent \advance \rightskip by \defbodyindent
  2069. \begingroup\obeylines\activeparens\spacesplit{#3{#4}}}
  2070.  
  2071. \def\defopparsebody #1#2#3#4#5 {\begingroup\inENV %
  2072. \medbreak %
  2073. % Define the end token that this defining construct specifies
  2074. % so that it will exit this group.
  2075. \def#1{\endgraf\endgroup\medbreak}%
  2076. \def#2##1 ##2 {\def#4{##1}%
  2077. \begingroup\obeylines\activeparens\spacesplit{#3{##2}}}%
  2078. \parindent=0in
  2079. \advance\leftskip by \defbodyindent \advance \rightskip by \defbodyindent
  2080. \begingroup\obeylines\activeparens\spacesplit{#3{#5}}}
  2081.  
  2082. % Split up #2 at the first space token.
  2083. % call #1 with two arguments:
  2084. %  the first is all of #2 before the space token,
  2085. %  the second is all of #2 after that space token.
  2086. % If #2 contains no space token, all of it is passed as the first arg
  2087. % and the second is passed as empty.
  2088.  
  2089. {\obeylines
  2090. \gdef\spacesplit#1#2^^M{\endgroup\spacesplitfoo{#1}#2 \relax\spacesplitfoo}%
  2091. \long\gdef\spacesplitfoo#1#2 #3#4\spacesplitfoo{%
  2092. \ifx\relax #3%
  2093. #1{#2}{}\else #1{#2}{#3#4}\fi}}
  2094.  
  2095. % So much for the things common to all kinds of definitions.
  2096.  
  2097. % Define @defun.
  2098.  
  2099. % First, define the processing that is wanted for arguments of \defun
  2100. % Use this to expand the args and terminate the paragraph they make up
  2101.  
  2102. \def\defunargs #1{\functionparens \sl
  2103. % Expand, preventing hyphenation at `-' chars.
  2104. % Note that groups don't affect changes in \hyphenchar.
  2105. \hyphenchar\sl=0
  2106. #1%
  2107. \hyphenchar\sl=45
  2108. \ifnum\parencount=0 \else \errmessage{unbalanced parens in @def arguments}\fi%
  2109. \interlinepenalty=10000
  2110. \advance\rightskip by 0pt plus 1fil
  2111. \endgraf\penalty 10000\vskip -\parskip\penalty 10000%
  2112. }
  2113.  
  2114. \def\deftypefunargs #1{%
  2115. % Expand, preventing hyphenation at `-' chars.
  2116. % Note that groups don't affect changes in \hyphenchar.
  2117. \functionparens
  2118. \code{#1}%
  2119. \interlinepenalty=10000
  2120. \advance\rightskip by 0pt plus 1fil
  2121. \endgraf\penalty 10000\vskip -\parskip\penalty 10000%
  2122. }
  2123.  
  2124. % Do complete processing of one @defun or @defunx line already parsed.
  2125.  
  2126. % @deffn Command forward-char nchars
  2127.  
  2128. \def\deffn{\defmethparsebody\Edeffn\deffnx\deffnheader}
  2129.  
  2130. \def\deffnheader #1#2#3{\doind {fn}{\code{#2}}%
  2131. \begingroup\defname {#2}{#1}\defunargs{#3}\endgroup %
  2132. \catcode 61=\other % Turn off change made in \defparsebody
  2133. }
  2134.  
  2135. % @defun == @deffn Function
  2136.  
  2137. \def\defun{\defparsebody\Edefun\defunx\defunheader}
  2138.  
  2139. \def\defunheader #1#2{\doind {fn}{\code{#1}}% Make entry in function index
  2140. \begingroup\defname {#1}{Function}%
  2141. \defunargs {#2}\endgroup %
  2142. \catcode 61=\other % Turn off change made in \defparsebody
  2143. }
  2144.  
  2145. % @deftypefun int foobar (int @var{foo}, float @var{bar})
  2146.  
  2147. \def\deftypefun{\defparsebody\Edeftypefun\deftypefunx\deftypefunheader}
  2148.  
  2149. % #1 is the data type.  #2 is the name and args.
  2150. \def\deftypefunheader #1#2{\deftypefunheaderx{#1}#2 \relax}
  2151. % #1 is the data type, #2 the name, #3 the args.
  2152. \def\deftypefunheaderx #1#2 #3\relax{\doind {fn}{\code{#2}}% Make entry in function index
  2153. \begingroup\defname {\code{#1} #2}{Function}%
  2154. \deftypefunargs {#3}\endgroup %
  2155. \catcode 61=\other % Turn off change made in \defparsebody
  2156. }
  2157.  
  2158. % @deftypefn {Library Function} int foobar (int @var{foo}, float @var{bar})
  2159.  
  2160. \def\deftypefn{\defmethparsebody\Edeftypefn\deftypefnx\deftypefnheader}
  2161.  
  2162. % #1 is the classification.  #2 is the data type.  #3 is the name and args.
  2163. \def\deftypefnheader #1#2#3{\deftypefnheaderx{#1}{#2}#3 \relax}
  2164. % #1 is the classification, #2 the data type, #3 the name, #4 the args.
  2165. \def\deftypefnheaderx #1#2#3 #4\relax{\doind {fn}{\code{#3}}% Make entry in function index
  2166. \begingroup\defname {\code{#2} #3}{#1}%
  2167. \deftypefunargs {#4}\endgroup %
  2168. \catcode 61=\other % Turn off change made in \defparsebody
  2169. }
  2170.  
  2171. % @defmac == @deffn Macro
  2172.  
  2173. \def\defmac{\defparsebody\Edefmac\defmacx\defmacheader}
  2174.  
  2175. \def\defmacheader #1#2{\doind {fn}{\code{#1}}% Make entry in function index
  2176. \begingroup\defname {#1}{Macro}%
  2177. \defunargs {#2}\endgroup %
  2178. \catcode 61=\other % Turn off change made in \defparsebody
  2179. }
  2180.  
  2181. % @defspec == @deffn Special Form
  2182.  
  2183. \def\defspec{\defparsebody\Edefspec\defspecx\defspecheader}
  2184.  
  2185. \def\defspecheader #1#2{\doind {fn}{\code{#1}}% Make entry in function index
  2186. \begingroup\defname {#1}{Special Form}%
  2187. \defunargs {#2}\endgroup %
  2188. \catcode 61=\other % Turn off change made in \defparsebody
  2189. }
  2190.  
  2191. % This definition is run if you use @defunx
  2192. % anywhere other than immediately after a @defun or @defunx.
  2193.  
  2194. \def\deffnx #1 {\errmessage{@deffnx in invalid context}}
  2195. \def\defunx #1 {\errmessage{@defunx in invalid context}}
  2196. \def\defmacx #1 {\errmessage{@defmacx in invalid context}}
  2197. \def\defspecx #1 {\errmessage{@defspecx in invalid context}}
  2198. \def\deftypefnx #1 {\errmessage{@deftypefnx in invalid context}}
  2199. \def\deftypeunx #1 {\errmessage{@deftypeunx in invalid context}}
  2200.  
  2201. % @defmethod, and so on
  2202.  
  2203. % @defop {Funny Method} foo-class frobnicate argument
  2204.  
  2205. \def\defop #1 {\def\defoptype{#1}%
  2206. \defopparsebody\Edefop\defopx\defopheader\defoptype}
  2207.  
  2208. \def\defopheader #1#2#3{\dosubind {fn}{\code{#2}}{on #1}% Make entry in function index
  2209. \begingroup\defname {#2}{\defoptype{} on #1}%
  2210. \defunargs {#3}\endgroup %
  2211. }
  2212.  
  2213. % @defmethod == @defop Method
  2214.  
  2215. \def\defmethod{\defmethparsebody\Edefmethod\defmethodx\defmethodheader}
  2216.  
  2217. \def\defmethodheader #1#2#3{\dosubind {fn}{\code{#2}}{on #1}% entry in function index
  2218. \begingroup\defname {#2}{Method on #1}%
  2219. \defunargs {#3}\endgroup %
  2220. }
  2221.  
  2222. % @defcv {Class Option} foo-class foo-flag
  2223.  
  2224. \def\defcv #1 {\def\defcvtype{#1}%
  2225. \defopparsebody\Edefcv\defcvx\defcvarheader\defcvtype}
  2226.  
  2227. \def\defcvarheader #1#2#3{%
  2228. \dosubind {vr}{\code{#2}}{of #1}% Make entry in var index
  2229. \begingroup\defname {#2}{\defcvtype{} of #1}%
  2230. \defvarargs {#3}\endgroup %
  2231. }
  2232.  
  2233. % @defivar == @defcv {Instance Variable}
  2234.  
  2235. \def\defivar{\defmethparsebody\Edefivar\defivarx\defivarheader}
  2236.  
  2237. \def\defivarheader #1#2#3{%
  2238. \dosubind {vr}{\code{#2}}{of #1}% Make entry in var index
  2239. \begingroup\defname {#2}{Instance Variable of #1}%
  2240. \defvarargs {#3}\endgroup %
  2241. }
  2242.  
  2243. % These definitions are run if you use @defmethodx, etc.,
  2244. % anywhere other than immediately after a @defmethod, etc.
  2245.  
  2246. \def\defopx #1 {\errmessage{@defopx in invalid context}}
  2247. \def\defmethodx #1 {\errmessage{@defmethodx in invalid context}}
  2248. \def\defcvx #1 {\errmessage{@defcvx in invalid context}}
  2249. \def\defivarx #1 {\errmessage{@defivarx in invalid context}}
  2250.  
  2251. % Now @defvar
  2252.  
  2253. % First, define the processing that is wanted for arguments of @defvar.
  2254. % This is actually simple: just print them in roman.
  2255. % This must expand the args and terminate the paragraph they make up
  2256. \def\defvarargs #1{\normalparens #1%
  2257. \interlinepenalty=10000
  2258. \endgraf\penalty 10000\vskip -\parskip\penalty 10000}
  2259.  
  2260. % @defvr Counter foo-count
  2261.  
  2262. \def\defvr{\defmethparsebody\Edefvr\defvrx\defvrheader}
  2263.  
  2264. \def\defvrheader #1#2#3{\doind {vr}{\code{#2}}%
  2265. \begingroup\defname {#2}{#1}\defvarargs{#3}\endgroup}
  2266.  
  2267. % @defvar == @defvr Variable
  2268.  
  2269. \def\defvar{\defparsebody\Edefvar\defvarx\defvarheader}
  2270.  
  2271. \def\defvarheader #1#2{\doind {vr}{\code{#1}}% Make entry in var index
  2272. \begingroup\defname {#1}{Variable}%
  2273. \defvarargs {#2}\endgroup %
  2274. }
  2275.  
  2276. % @defopt == @defvr {User Option}
  2277.  
  2278. \def\defopt{\defparsebody\Edefopt\defoptx\defoptheader}
  2279.  
  2280. \def\defoptheader #1#2{\doind {vr}{\code{#1}}% Make entry in var index
  2281. \begingroup\defname {#1}{User Option}%
  2282. \defvarargs {#2}\endgroup %
  2283. }
  2284.  
  2285. % @deftypevar int foobar
  2286.  
  2287. \def\deftypevar{\defparsebody\Edeftypevar\deftypevarx\deftypevarheader}
  2288.  
  2289. % #1 is the data type.  #2 is the name.
  2290. \def\deftypevarheader #1#2{\doind {vr}{\code{#2}}% Make entry in variables index
  2291. \begingroup\defname {\code{#1} #2}{Variable}%
  2292. \interlinepenalty=10000
  2293. \endgraf\penalty 10000\vskip -\parskip\penalty 10000
  2294. \endgroup}
  2295.  
  2296. % @deftypevr {Global Flag} int enable
  2297.  
  2298. \def\deftypevr{\defmethparsebody\Edeftypevr\deftypevrx\deftypevrheader}
  2299.  
  2300. \def\deftypevrheader #1#2#3{\doind {vr}{\code{#3}}%
  2301. \begingroup\defname {\code{#2} #3}{#1}
  2302. \interlinepenalty=10000
  2303. \endgraf\penalty 10000\vskip -\parskip\penalty 10000
  2304. \endgroup}
  2305.  
  2306. % This definition is run if you use @defvarx
  2307. % anywhere other than immediately after a @defvar or @defvarx.
  2308.  
  2309. \def\defvrx #1 {\errmessage{@defvrx in invalid context}}
  2310. \def\defvarx #1 {\errmessage{@defvarx in invalid context}}
  2311. \def\defoptx #1 {\errmessage{@defoptx in invalid context}}
  2312. \def\deftypevarx #1 {\errmessage{@deftypevarx in invalid context}}
  2313. \def\deftypevrx #1 {\errmessage{@deftypevrx in invalid context}}
  2314.  
  2315. % Now define @deftp
  2316. % Args are printed in bold, a slight difference from @defvar.
  2317.  
  2318. \def\deftpargs #1{\bf \defvarargs{#1}}
  2319.  
  2320. % @deftp Class window height width ...
  2321.  
  2322. \def\deftp{\defmethparsebody\Edeftp\deftpx\deftpheader}
  2323.  
  2324. \def\deftpheader #1#2#3{\doind {tp}{\code{#2}}%
  2325. \begingroup\defname {#2}{#1}\deftpargs{#3}\endgroup}
  2326.  
  2327. % This definition is run if you use @deftpx, etc
  2328. % anywhere other than immediately after a @deftp, etc.
  2329.  
  2330. \def\deftpx #1 {\errmessage{@deftpx in invalid context}}
  2331.  
  2332. \message{cross reference,}
  2333. % Define cross-reference macros
  2334. \newwrite \auxfile
  2335.  
  2336. \newif\ifhavexrefs  % True if xref values are known.
  2337. \newif\ifwarnedxrefs  % True if we warned once that they aren't known.
  2338.  
  2339. % \setref{foo} defines a cross-reference point named foo.
  2340.  
  2341. \def\setref#1{%
  2342. %\dosetq{#1-title}{Ytitle}%
  2343. \dosetq{#1-pg}{Ypagenumber}%
  2344. \dosetq{#1-snt}{Ysectionnumberandtype}}
  2345.  
  2346. \def\unnumbsetref#1{%
  2347. %\dosetq{#1-title}{Ytitle}%
  2348. \dosetq{#1-pg}{Ypagenumber}%
  2349. \dosetq{#1-snt}{Ynothing}}
  2350.  
  2351. \def\appendixsetref#1{%
  2352. %\dosetq{#1-title}{Ytitle}%
  2353. \dosetq{#1-pg}{Ypagenumber}%
  2354. \dosetq{#1-snt}{Yappendixletterandtype}}
  2355.  
  2356. % \xref, \pxref, and \ref generate cross-references to specified points.
  2357. % For \xrefX, #1 is the node name, #2 the name of the Info
  2358. % cross-reference, #3 the printed node name, #4 the name of the Info
  2359. % file, #5 the name of the printed manual.  All but the node name can be
  2360. % omitted.
  2361. \def\pxref#1{see \xrefX[#1,,,,,,,]}
  2362. \def\xref#1{See \xrefX[#1,,,,,,,]}
  2363. \def\ref#1{\xrefX[#1,,,,,,,]}
  2364. \def\xrefX[#1,#2,#3,#4,#5,#6]{\begingroup%
  2365. \def\printedmanual{\ignorespaces #5}%
  2366. \def\printednodename{\ignorespaces #3}%
  2367. %
  2368. \setbox1=\hbox{\printedmanual}%
  2369. \setbox0=\hbox{\printednodename}%
  2370. \ifdim \wd0=0pt%
  2371. \def\printednodename{\ignorespaces #1}%
  2372. %%% Uncommment the following line to make the actual chapter or section title
  2373. %%% appear inside the square brackets.
  2374. %\def\printednodename{#1-title}%
  2375. \fi%
  2376. %
  2377. %
  2378. % If we use \unhbox0 and \unhbox1 to print the node names, TeX does
  2379. % not insert empty discretionaries after hyphens, which means that it
  2380. % will not find a line break at a hyphen in a node names.  Since some
  2381. % manuals are best written with fairly long node names, containing
  2382. % hyphens, this is a loss.  Therefore, we simply give the text of
  2383. % the node name again, so it is as if TeX is seeing it for the first
  2384. % time.
  2385. \ifdim \wd1>0pt
  2386. section ``\printednodename'' in \cite{\printedmanual}%
  2387. \else%
  2388. \turnoffactive%
  2389. \refx{#1-snt}{} [\printednodename], page\tie\refx{#1-pg}{}%
  2390. \fi
  2391. \endgroup}
  2392.  
  2393. % \dosetq is the interface for calls from other macros
  2394.  
  2395. % Use \turnoffactive so that punctuation chars such as underscore
  2396. % work in node names.
  2397. \def\dosetq #1#2{{\let\folio=0 \turnoffactive%
  2398. \edef\next{\write\auxfile{\internalsetq {#1}{#2}}}%
  2399. \next}}
  2400.  
  2401. % \internalsetq {foo}{page} expands into CHARACTERS 'xrdef {foo}{...expansion of \Ypage...}
  2402. % When the aux file is read, ' is the escape character
  2403.  
  2404. \def\internalsetq #1#2{'xrdef {#1}{\csname #2\endcsname}}
  2405.  
  2406. % Things to be expanded by \internalsetq
  2407.  
  2408. \def\Ypagenumber{\folio}
  2409.  
  2410. \def\Ytitle{\thischapter}
  2411.  
  2412. \def\Ynothing{}
  2413.  
  2414. \def\Ysectionnumberandtype{%
  2415. \ifnum\secno=0 Chapter\xreftie\the\chapno %
  2416. \else \ifnum \subsecno=0 Section\xreftie\the\chapno.\the\secno %
  2417. \else \ifnum \subsubsecno=0 %
  2418. Section\xreftie\the\chapno.\the\secno.\the\subsecno %
  2419. \else %
  2420. Section\xreftie\the\chapno.\the\secno.\the\subsecno.\the\subsubsecno %
  2421. \fi \fi \fi }
  2422.  
  2423. \def\Yappendixletterandtype{%
  2424. \ifnum\secno=0 Appendix\xreftie'char\the\appendixno{}%
  2425. \else \ifnum \subsecno=0 Section\xreftie'char\the\appendixno.\the\secno %
  2426. \else \ifnum \subsubsecno=0 %
  2427. Section\xreftie'char\the\appendixno.\the\secno.\the\subsecno %
  2428. \else %
  2429. Section\xreftie'char\the\appendixno.\the\secno.\the\subsecno.\the\subsubsecno %
  2430. \fi \fi \fi }
  2431.  
  2432. \gdef\xreftie{'tie}
  2433.  
  2434. % Use TeX 3.0's \inputlineno to get the line number, for better error
  2435. % messages, but if we're using an old version of TeX, don't do anything.
  2436. \ifx\inputlineno\thisisundefined
  2437.   \let\linenumber = \empty % Non-3.0.
  2438. \else
  2439.   \def\linenumber{\the\inputlineno:\space}
  2440. \fi
  2441.  
  2442. % Define \refx{NAME}{SUFFIX} to reference a cross-reference string named NAME.
  2443. % If its value is nonempty, SUFFIX is output afterward.
  2444.  
  2445. \def\refx#1#2{%
  2446.   \expandafter\ifx\csname X#1\endcsname\relax
  2447.     % If not defined, say something at least.
  2448.     $\langle$un\-de\-fined$\rangle$%
  2449.     \ifhavexrefs
  2450.       \message{\linenumber Undefined cross reference `#1'.}%
  2451.     \else
  2452.       \ifwarnedxrefs\else
  2453.         \global\warnedxrefstrue
  2454.         \message{Cross reference values unknown; you must run TeX again.}%
  2455.       \fi
  2456.     \fi
  2457.   \else
  2458.     % It's defined, so just use it.
  2459.     \csname X#1\endcsname
  2460.   \fi
  2461.   #2% Output the suffix in any case.
  2462. }
  2463.  
  2464. % Read the last existing aux file, if any.  No error if none exists.
  2465.  
  2466. % This is the macro invoked by entries in the aux file.
  2467. \def\xrdef #1#2{
  2468. {\catcode`\'=\other\expandafter \gdef \csname X#1\endcsname {#2}}}
  2469.  
  2470. \def\readauxfile{%
  2471. \begingroup
  2472. \catcode `\^^@=\other
  2473. \catcode `\=\other
  2474. \catcode `\=\other
  2475. \catcode `\^^C=\other
  2476. \catcode `\^^D=\other
  2477. \catcode `\^^E=\other
  2478. \catcode `\^^F=\other
  2479. \catcode `\^^G=\other
  2480. \catcode `\^^H=\other
  2481. \catcode `\ =\other
  2482. \catcode `\^^L=\other
  2483. \catcode `\=\other
  2484. \catcode `\=\other
  2485. \catcode `\=\other
  2486. \catcode `\=\other
  2487. \catcode `\=\other
  2488. \catcode `\=\other
  2489. \catcode `\=\other
  2490. \catcode `\=\other
  2491. \catcode `\=\other
  2492. \catcode `\=\other
  2493. \catcode `\=\other
  2494. \catcode `\=\other
  2495. \catcode `\=\other
  2496. \catcode `\^^[=\other
  2497. \catcode `\^^\=\other
  2498. \catcode `\^^]=\other
  2499. \catcode `\^^^=\other
  2500. \catcode `\^^_=\other
  2501. \catcode `\@=\other
  2502. \catcode `\^=\other
  2503. \catcode `\~=\other
  2504. \catcode `\[=\other
  2505. \catcode `\]=\other
  2506. \catcode`\"=\other
  2507. \catcode`\_=\other
  2508. \catcode`\|=\other
  2509. \catcode`\<=\other
  2510. \catcode`\>=\other
  2511. \catcode `\$=\other
  2512. \catcode `\#=\other
  2513. \catcode `\&=\other
  2514. % the aux file uses ' as the escape.
  2515. % Turn off \ as an escape so we do not lose on
  2516. % entries which were dumped with control sequences in their names.
  2517. % For example, 'xrdef {$\leq $-fun}{page ...} made by @defun ^^
  2518. % Reference to such entries still does not work the way one would wish,
  2519. % but at least they do not bomb out when the aux file is read in.
  2520. \catcode `\{=1 \catcode `\}=2
  2521. \catcode `\%=\other
  2522. \catcode `\'=0
  2523. \catcode `\\=\other
  2524. \openin 1 \jobname.aux
  2525. \ifeof 1 \else \closein 1 \input \jobname.aux \global\havexrefstrue
  2526. \fi
  2527. % Open the new aux file.  Tex will close it automatically at exit.
  2528. \openout \auxfile=\jobname.aux
  2529. \endgroup}
  2530.  
  2531.  
  2532. % Footnotes.
  2533.  
  2534. \newcount \footnoteno
  2535.  
  2536. \def\supereject{\par\penalty -20000\footnoteno =0 }
  2537.  
  2538. \let\ptexfootnote=\footnote
  2539.  
  2540. {\catcode `\@=11
  2541. \long\gdef\footnote #1{\global\advance \footnoteno by \@ne
  2542. \removelastskip
  2543. \edef\thisfootno{$^{\the\footnoteno}$}%
  2544. \let\@sf\empty
  2545. \ifhmode\edef\@sf{\spacefactor\the\spacefactor}\/\fi
  2546. \thisfootno\@sf \footnotezzz{#1}}
  2547. % \parsearg\footnotezzz}
  2548.  
  2549. \long\gdef\footnotezzz #1{\insert\footins{
  2550. \interlinepenalty\interfootnotelinepenalty
  2551. \splittopskip\ht\strutbox % top baseline for broken footnotes
  2552. \splitmaxdepth\dp\strutbox \floatingpenalty\@MM
  2553. \leftskip\z@skip \rightskip\z@skip \spaceskip\z@skip \xspaceskip\z@skip
  2554. \footstrut\parindent=\defaultparindent\hang\textindent{\thisfootno}#1\strut}}
  2555.  
  2556. }%end \catcode `\@=11
  2557.  
  2558. % End of control word definitions.
  2559.  
  2560. \message{and turning on texinfo input format.}
  2561.  
  2562. \def\openindices{%
  2563.    \newindex{cp}%
  2564.    \newcodeindex{fn}%
  2565.    \newcodeindex{vr}%
  2566.    \newcodeindex{tp}%
  2567.    \newcodeindex{ky}%
  2568.    \newcodeindex{pg}%
  2569. }
  2570.  
  2571. % Set some numeric style parameters, for 8.5 x 11 format.
  2572.  
  2573. %\hsize = 6.5in
  2574. \newdimen\defaultparindent \defaultparindent = 15pt
  2575. \parindent = \defaultparindent
  2576. \parskip 18pt plus 1pt
  2577. \baselineskip 15pt
  2578. \advance\topskip by 1.2cm
  2579.  
  2580. % Prevent underfull vbox error messages.
  2581. \vbadness=10000
  2582.  
  2583. % Use TeX 3.0's \emergencystretch to help line breaking, but if we're
  2584. % using an old version of TeX, don't do anything.  We want the amount of
  2585. % stretch added to depend on the line length, hence the dependence on
  2586. % \hsize.  This makes it come to about 9pt for the 8.5x11 format.
  2587. \ifx\emergencystretch\thisisundefined \else
  2588.   \emergencystretch = \hsize
  2589.   \divide\emergencystretch by 45
  2590. \fi
  2591.  
  2592. % Use @smallbook to reset parameters for 7x9.5 format
  2593. \def\smallbook{
  2594. \global\lispnarrowing = 0.3in
  2595. \global\baselineskip 12pt
  2596. \global\parskip 3pt plus 1pt
  2597. \global\hsize = 5in
  2598. \global\doublecolumnhsize=2.4in \global\doublecolumnvsize=15.0in
  2599. \global\vsize=7.5in
  2600. \global\tolerance=700
  2601. \global\hfuzz=1pt
  2602.  
  2603. \global\pagewidth=\hsize
  2604. \global\pageheight=\vsize
  2605.  
  2606. \global\let\smalllisp=\smalllispx
  2607. \global\let\smallexample=\smalllispx
  2608. \global\def\Esmallexample{\Esmalllisp}
  2609. }
  2610.  
  2611. %% For a final copy, take out the rectangles
  2612. %% that mark overfull boxes (in case you have decided
  2613. %% that the text looks ok even though it passes the margin).
  2614. \def\finalout{\overfullrule=0pt}
  2615.  
  2616. % Define macros to output various characters with catcode for normal text.
  2617. \catcode`\"=\other
  2618. \catcode`\~=\other
  2619. \catcode`\^=\other
  2620. \catcode`\_=\other
  2621. \catcode`\|=\other
  2622. \catcode`\<=\other
  2623. \catcode`\>=\other
  2624. \catcode`\+=\other
  2625. \def\normaldoublequote{"}
  2626. \def\normaltilde{~}
  2627. \def\normalcaret{^}
  2628. \def\normalunderscore{_}
  2629. \def\normalverticalbar{|}
  2630. \def\normalless{<}
  2631. \def\normalgreater{>}
  2632. \def\normalplus{+}
  2633.  
  2634. % This macro is used to make a character print one way in ttfont
  2635. % where it can probably just be output, and another way in other fonts,
  2636. % where something hairier probably needs to be done.
  2637. %
  2638. % #1 is what to print if we are indeed using \tt; #2 is what to print
  2639. % otherwise.  Since all the Computer Modern typewriter fonts have zero
  2640. % interword stretch (and shrink), and it is reasonable to expect all
  2641. % typewriter fonts to have this, we can check that font parameter.
  2642. \def\ifusingtt#1#2{\ifdim \fontdimen3\the\font=0pt #1\else #2\fi}
  2643.  
  2644. % Turn off all special characters except @
  2645. % (and those which the user can use as if they were ordinary).
  2646. % Most of these we simply print from the \tt font, but for some, we can
  2647. % use math or other variants that look better in normal text.
  2648.  
  2649. \catcode`\"=\active
  2650. \def\activedoublequote{{\tt \char '042}}
  2651. \let"=\activedoublequote
  2652. \catcode`\~=\active
  2653. \def~{{\tt \char '176}}
  2654. \chardef\hat=`\^
  2655. \catcode`\^=\active
  2656. \def^{{\tt \hat}}
  2657.  
  2658. \catcode`\_=\active
  2659. \def_{\ifusingtt\normalunderscore\_}
  2660. % Subroutine for the previous macro.
  2661. \def\_{\leavevmode \kern.06em \vbox{\hrule width.3em height.1ex}}
  2662.  
  2663. \catcode`\|=\active
  2664. \def|{{\tt \char '174}}
  2665. \chardef \less=`\<
  2666. \catcode`\<=\active
  2667. \def<{{\tt \less}}
  2668. \chardef \gtr=`\>
  2669. \catcode`\>=\active
  2670. \def>{{\tt \gtr}}
  2671. \catcode`\+=\active
  2672. \def+{{\tt \char 43}}
  2673. %\catcode 27=\active
  2674. %\def^^[{$\diamondsuit$}
  2675.  
  2676. % Used sometimes to turn off (effectively) the active characters
  2677. % even after parsing them.
  2678. \def\turnoffactive{\let"=\normaldoublequote
  2679. \let~=\normaltilde
  2680. \let^=\normalcaret
  2681. \let_=\normalunderscore
  2682. \let|=\normalverticalbar
  2683. \let<=\normalless
  2684. \let>=\normalgreater
  2685. \let+=\normalplus}
  2686.  
  2687. % Set up an active definition for =, but don't enable it most of the time.
  2688. {\catcode`\==\active
  2689. \global\def={{\tt \char 61}}}
  2690.  
  2691. \catcode`\@=0
  2692.  
  2693. % \rawbackslashxx output one backslash character in current font
  2694. \global\chardef\rawbackslashxx=`\\
  2695. %{\catcode`\\=\other
  2696. %@gdef@rawbackslashxx{\}}
  2697.  
  2698. % \rawbackslash redefines \ as input to do \rawbackslashxx.
  2699. {\catcode`\\=\active
  2700. @gdef@rawbackslash{@let\=@rawbackslashxx }}
  2701.  
  2702. % \normalbackslash outputs one backslash in fixed width font.
  2703. \def\normalbackslash{{\tt\rawbackslashxx}}
  2704.  
  2705. % Say @foo, not \foo, in error messages.
  2706. \escapechar=`\@
  2707.  
  2708. % \catcode 17=0   % Define control-q
  2709. \catcode`\\=\active
  2710.  
  2711. % If a .fmt file is being used, we don't want the `\input texinfo' to show up.
  2712. % That is what \eatinput is for; after that, the `\' should revert to printing 
  2713. % a backslash.
  2714. %
  2715. @gdef@eatinput input texinfo{@fixbackslash}
  2716. @global@let\ = @eatinput
  2717.  
  2718. % On the other hand, perhaps the file did not have a `\input texinfo'. Then
  2719. % the first `\{ in the file would cause an error. This macro tries to fix 
  2720. % that, assuming it is called before the first `\' could plausibly occur.
  2721. @gdef@fixbackslash{@ifx\@eatinput @let\ = @normalbackslash @fi}
  2722.  
  2723. %% These look ok in all fonts, so just make them not special.  The @rm below
  2724. %% makes sure that the current font starts out as the newly loaded cmr10
  2725. @catcode`@$=@other @catcode`@%=@other @catcode`@&=@other @catcode`@#=@other
  2726.  
  2727. @textfonts
  2728. @rm
  2729.